[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XTTE0510 ISSUE.

Subject: XTTE0510 ISSUE.
From: chun ji <cji_work@xxxxxxxxx>
Date: Mon, 18 Aug 2008 13:43:28 -0700 (PDT)
  XTTE0510 ISSUE.
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.