Hi Ken,
thank you for the tips and that does solve my problem.
For those interested, here is my updated xsl file:
"
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="xml" indent="yes"/>
<xsl:variable name="doc2"
select="document('testcases.xml')"/>
<xsl:template match="/">
<TestCases>
<xsl:apply-templates />
</TestCases>
</xsl:template>
<xsl:template match="Obj">
<xsl:variable name="objName" select="@name"/>
<xsl:variable name="caseString" select =
"$doc2//obj[(_at_)name = $objName]/@cases"/>
<xsl:variable name="caseArray"
select="tokenize($caseString, ',')"/>
<xsl:variable name="Obj" select="."/>
<xsl:for-each select="$caseArray">
<obj>
<xsl:variable name="a"
select="position()"/>
<xsl:attribute name="name">
<xsl:value-of
select="$objName"/>
</xsl:attribute>
<xsl:attribute name="case">
<xsl:value-of
select="$caseArray[$a]"/>
</xsl:attribute>
<xsl:apply-templates
select="$Obj/node()"/>
</obj>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
"
-c
--- "G. Ken Holman" <gkholman(_at_)CraneSoftwrights(_dot_)com>
wrote:
At 2008-08-18 13:43 -0700, chun ji wrote:
Here is my XSL file that does not work,
<xsl:template match="Obj">
<xsl:variable name="objName"
select="@name"/>
<xsl:variable name="caseString" select =
"$doc2//obj[(_at_)name = $objName]/@cases"/>
<xsl:variable name="caseArray"
select="tokenize($caseString, ',')"/>
<xsl:for-each select="$caseArray">
Here you are iterating over a set of strings
returned from tokenize().
<xsl:apply-templates />
And you are not in any node tree, so there is no
way to push any nodes at your stylesheet. Your
current context item is a string value.
¡°XTTE0510: Cannot apply-templates to child nodes
when
the context item is an atomic value¡±.
Which is why you get the error.
If you wanted to push the node children of Obj
then put Obj into a variable and use:
<xsl:apply-templates select="$Obj/node()"/>
I hope this helps.
. . . . . . . . . . . . . Ken
--
Upcoming XSLT/XSL-FO hands-on courses:
Wellington, NZ 2009-01
Training tools: Comprehensive interactive XSLT/XPath
1.0/2.0 video
G. Ken Holman
mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
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
--~------------------------------------------------------------------
XSL-List info and archive:
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--