Subject: Re: [xsl] Mixing sources to create a pattern From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 22 Dec 2008 21:11:13 -0500 |
I have two standalone xml files, strucure.xml and data.xml. I also have the XSLT file layout.xsl.
layout.xsl is being applied to structure.xml, and data.xml is being used in layout.xsl like below:
<xsl:variable name="data" select="document('data.xml')/data" />
In layout.xsl i'm in a loop below:
<xsl:for-each select="some_tag"> <div id="{@id}" class="{$data/@id}">...</div> </xsl:for-each>
So if structure.xml has <some_tag id="test_id" /> and data.xml has <data><test_id>test_class</test_id></data> I want a transformation of <div id="test_id" class="test_class">...</div>.
<xsl:for-each select="some_tag"> <div id="{@id}" class="{$data/*[name(.)=current()/@id]}">...</div> </xsl:for-each>
<!--load up a key table with children of data, indexed by name--> <xsl:key name="'data'" match="data/*" use="name(.)"/>
<xsl:for-each select="some_tag"> <div id="{@id}"> <xsl:variable name="id" select="@id"/> <xsl:for-each select="document('data.xml')"> <xsl:attribute name="class"> <xsl:value-of select="key('data',$id)"/> </xsl:attribute> </xsl:for-each> ... </div> </xsl:for-each>
<!--load up a key table with children of data, indexed by name--> <xsl:key name="'data'" match="data/*" use="name(.)"/>
<xsl:for-each select="some_tag"> <div id="{@id}" class="{key('data',@id,document('data.xml'))}">...</div> </xsl:for-each>
Why does this not work
and is their a solution to create a pattern mixing these different xml sources?
-- Upcoming XSLT/XSL-FO, UBL and code list hands-on training classes: : Sydney, AU 2009-01/02; Brussels, BE 2009-03; Prague, CZ 2009-03 Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video sample lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg Video course overview: http://www.youtube.com/watch?v=VTiodiij6gE G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Mixing sources to create a pa, Andrew Ferk | Thread | [no subject], Unknown |
[xsl] Mixing sources to create a pa, Andrew Ferk | Date | [no subject], Unknown |
Month |