Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: nested xsl:for-each with document function >Thread Next - Re: nested xsl:for-each with document function Re: nested xsl:for-each with document functionTo: NULL Date: 9/10/2009 5:20:00 AM On Sep 10, 1:54=A0pm, Martin Honnen <mahotr...@yahoo.de> wrote:
> Cozmo wrote:
> > Hello,
>
> > I want to do a nested xsl:for-each with the document function.
>
> > Here is a code snippet but it is not working:
>
> > <xsl:variable name=3D"cc" select=3D"lower-case(../code-2)"/>
> > =A0 =A0 =A0 =A0 <xsl:variable name=3D"names_DA" select=3D"document('exp=
ort.xml')/
> > translation/record[iso.code2=3D$cc]"/>
> > =A0 =A0<xsl:variable name=3D"lgs" select=3D"lg.vers"/>
> > =A0 =A0<xsl:for-each select=3D"$names_DA">
> > =A0 =A0 =A0 =A0 =A0 =A0<xsl:for-each select=3D"$lgs">
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<xsl:choose>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<xsl:when test=
=3D"@lg=3D$names_DA/source.lang"/>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<xsl:otherwise>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
<xsl:element name=3D"lg.vers">
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0<xsl:attribute name=3D"lg"><xsl:value-of select=3D"$names_D=
A/
> > source.lang"/></xsl:attribute>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0<xsl:value-of select=3D"$names_DA/short.name"/>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
</xsl:element>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0</xsl:otherwise>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0</xsl:choose>
> > =A0 =A0 =A0 =A0 =A0 =A0</xsl:for-each>
> > =A0 =A0</xsl:for-each>
>
> > The problem I have is that I have to run through all entries of the
> > external document (with restriction) and afterwards check the other
> > restrictions in the second for-each. I want to check if the entries
> > already exists and if not I have to add them out of the external
> > docoument.
>
> > if I use this one:
> > <xsl:value-of select=3D"$names_DA/short.name"/>
> > I get entries but it returns the complete records and not only the
> > current one of the for-each loop.
>
> > Hope this explains the problem. Would be happy for any help!
>
> So you have two XML input documents and want to process them and compare
> nodes. Please show us relevant sample of the two documents and explain
> the XML output you want the stylesheet to create for those two samples.
>
> --
>
> =A0 =A0 =A0 =A0 Martin Honnen
> =A0 =A0 =A0 =A0http://msmvps.com/blogs/martin_honnen/
Hello,
No I have one input document and want to transform it via saxon. But I
need data from a second one so I use the document function. (merge the
information)
First input file:
<record>
<c2>AD</c2>
<c3>AS</c3>
<cn>002</cn>
<short.name>
<lg.vers lg=3D"ss">text</lg.vers>
<lg.vers lg=3D"tt">text</lg.vers>
<lg.vers lg=3D"ts">text</lg.vers>
....
the file which I import via the document function:
<record>
<short.name>test</short.name>
<long.name>text</long.name>
<iso.code2>AD</iso.code2>
<source.lang>bg</source.lang>
</record>
<record>
<short.name>test</short.name>
<long.name>text</long.name>
<iso.code2>AD</iso.code2>
<source.lang>tt</source.lang>
</record>
<record>
<short.name>test</short.name>
<long.name>text</long.name>
<iso.code2>DZ</iso.code2>
<source.lang>bg</source.lang>
</record>
In the second file are additional information which I want to Add as a
node. Example:
<lg.vers lg=3D"bg">test</lg.vers> should be added.
As you can see first restriction c2 =3D iso.code2.
Second restriction add elemnt only if source.lang doesnt exist list.
( So, @lg =3D tt shouldn't be added)
Someting like that "c2 =3D iso.code2 and sourcelang !=3D @lg"
But as I have to loop through all these items its difficult.
Any idea? Hope this explains the problem.
Thanks for helping.
Greets,
Cozmo
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
