Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Updated >Thread Next - Re: Updated Re: UpdatedTo: NULL Date: 10/5/2004 12:09:00 PM Thanks! That was perfect! You are the XSL Master!
Another question: What if there was an attribute called "FRIEND" which
needed to be persisted for every persisted "id" in the source document to
the target document. For example:
<foo>
<xs a="mappable" b="mappable" c="mappable">
<x id="1111" FRIEND="1111 FRIEND BOB" a="2222" c="3333"
house="home">
<x id="4444" FRIEND="4444 FRIEND ALEX" a="5555" c="6666"
house="home">
</xs>
<ys j="mappable">
<y id="7777" FRIEND="7777 FRIEND JANET" j="8888" house="home">
</ys>
</foo>
to
<uniques>
<unique id="1111" FRIEND="1111 FRIEND BOB">
<unique id="2222">
<unique id="3333">
<unique id="4444" FRIEND="4444 FRIEND ALEX">
<unique id="5555">
<unique id="6666">
<unique id="7777" FRIEND="7777 FRIEND JANET">
<unique id="8888">
</uniques>
But 2222, 3333, 5555, 6666 and 8888 never have a friend cus they are from
mappables
"Marrow" <m--a-r-r-o-w@m-a-r-r-o-w--s-o-f-t.com> wrote in message
news:OR7en8sqEHA.2724@T......
> Hi,
>
> Something like...
>
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:key name="kDistinctID" match="/*/*/*/@*" use="."/>
>
> <!-- key for determining if a given attribute has an an attribute in
its -->
> <!-- parent/parent with the same name and a value of 'mappable' -->
> <xsl:key name="kIsMappable" match="@*[. = 'mappable']"
> use="concat(generate-id(..),'|',name())"/>
>
> <xsl:template match="/">
> <uniques>
> <xsl:for-each select="/*/*/*/@*[name() = 'id' or
> key('kIsMappable',concat(generate-id(../..),'|',name()))][generate-id() =
> generate-id(key('kDistinctID',.)[name() = 'id' or
> key('kIsMappable',concat(generate-id(../..),'|',name()))])]">
> <unique id="{.}"/>
> </xsl:for-each>
> </uniques>
> </xsl:template>
> </xsl:stylesheet>
>
>
> HTH
> Marrow
> http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
> http://www.topxml.com/Xselerator
>
>
> "Daniel" <softwareengineer98037@y...> wrote in message
> news:%235u3HcnqEHA.2924@T......
> > Let me re explain my question better then:
> >
> > Basically I would like there to be two ways for an attributes to get
into
> > the output document.
> > 1. If the attribute's elements parent has an attribute with the same
name
> > and a value of "mappable"
> > 2. If the attribute is named "id"
> >
> > As for this resulting list of id's I would like it to be a unique list.
> > For example:
> > <foo>
> > <xs a="mappable" b="mappable" c="mappable">
> > <x id="1111" a="2222" c="3333" house="home">
> > <x id="4444" a="5555" c="6666" house="home">
> > </xs>
> > <ys j="mappable">
> > <y id="7777" j="8888" house="home">
> > </ys>
> > </foo>
> >
> > to
> >
> > <uniques>
> > <unique id="1111">
> > <unique id="2222">
> > <unique id="3333">
> > <unique id="4444">
> > <unique id="5555">
> > <unique id="6666">
> > <unique id="7777">
> > <unique id="8888">
> > </uniques>
> >
> >
>
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
