|
Subject: [xsl] apply-template inside xsl:variable returns a documentFragment with a child node tree From: "John P. Flanigan [Software Technology Initiative, Inc.]" <JFlanigan@xxxxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 24 Feb 2006 05:47:35 -0500 |
I have an xml document in another namespace that I am performing a lookup
on. The result should be a single node (having attributes and elements). I
am assigning the result of this lookup to a variable so that the attributes
and elements can be accessed if and when needed without multiple lookups.
My problem is that I am getting the desired node as a child of a
documentFragment. I haven't a clue as to what a documentFragment is, why am
I getting it, how to get rid of it or otherwise work around it.
Here is the pertinent code:
<xsl:variable name="elementContent"
select="document('content.xml')/c:content/c:elements"/>
<xsl:key name="elementContentKey" match="c:element" use="@id"/>
<xsl:template match="c:elements">
<xsl:param name="elementName"/>
<xsl:copy-of select="key('elementContentKey', $elementName )"/>
</xsl:template>
and then in a template (in which context, @name is valued), I define the
variable $thisContent.
<xsl:variable name="thisContent">
<xsl:apply-templates select="$elementContent">
<xsl:with-param name="elementName" select="@name"/>
</xsl:apply-templates>
</xsl:variable>
The file content.xml has a structure like
<content>
<elements>
<element id="table">
<caption>Table</caption>
<description>Name of table in database</description>
<help href="table.help"/>
</element>
</elements>
...
</content>
I would like $thisContent to be equivalent to the single <element> shown
above, when @name = "table".
Thanks for any consideration of my problem.
Regards,
John
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Separating layout and content, Lensch, Thomas | Thread | Re: [xsl] apply-template inside xsl, David Carlisle |
| Re: [xsl] select immediately follow, James A. Robinson | Date | Re: [xsl] apply-template inside xsl, David Carlisle |
| Month |