|
Subject: [xsl] XTTE0510 ISSUE. From: chun ji <cji_work@xxxxxxxxx> Date: Mon, 18 Aug 2008 13:43:28 -0700 (PDT) |
Hi there,
I have 2 xml files that need to be mixed together.
1."Input.xml"
"
<?xml version="1.0" encoding="UTF-8"?>
<Obj name="a">
<Obj name="c">
<Obj name=!1b!1/>
</Obj>
</Obj>
"
2. "testcases.xml"
!0
<?xml version="1.0" encoding="utf-8"?>
<Objs>
<obj name="a" cases="a1,a2,a3"/>
<obj name="b" cases="b1,b2"/>
<obj name="c" cases="c1,c2"/>
</Objs>
!0
And I was expecting to create the output file as:
!0
<TestCases>
<Obj name=!1a!1 case=!1a1!1>
<Obj name=!1c!1 case=!1c1!1>
<Obj name=!1b1!1/>
<Obj name=!1b2!1/>
</Obj>
<Obj name=!1c!1 case=!1c2!1>
<Obj name=!1b1!1/>
<Obj name=!1b2!1/>
</Obj>
</Obj>
<Obj name=!1a!1 case=!1a2!1>
...
</Obj>
....
</TestCases>
!0
Here is my XSL file that does not work,
!0
<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[@name = $objName]/@cases"/>
<xsl:variable name="caseArray"
select="tokenize($caseString, ',')"/>
<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 />
</obj>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
!0
Basically it complains for this line:
!0
<xsl:apply-templates />
!0
as
!0XTTE0510: Cannot apply-templates to child nodes when
the context item is an atomic value!1.
Thanks a lot for the help
Chun
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] nbsp and copy-of and outp, Andrew Welch | Thread | Re: [xsl] XTTE0510 ISSUE., G. Ken Holman |
| Re: [xsl] nbsp and copy-of and outp, Andrew Welch | Date | Re: [xsl] flattening and re-orderin, Andrew Welch |
| Month |