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

Re: create xml from incoming xml and load it into a v

Subject: Re: create xml from incoming xml and load it into a variable
From: sudheshna iyer <sudheshnaiyer@xxxxxxxxx>
Date: Fri, 25 Jul 2008 13:37:27 -0700 (PDT)
Re:  create xml from incoming xml and load it into a  v
Thank you.

I did this using:
	<xsl:template match="root">
	  <xsl:variable name="var">
	    <xsl:element name="subroot" use-attribute-sets="id">
		<xsl:apply-templates select="bbb"/>
	    </xsl:element>
	  </xsl:variable>
	  
	  <!--Traverse the variable-->
	  <xsl:for-each select="xalan:nodeset($var)/root/subroot">
	    <xsl:key name="ccc" match="subroot" use="11"/> ===> ERROR!!!!
	  </xsl:for-each>
	</xsl:template>

Sample xml:
<?xml version="1.0" encoding="UTF-8"?>
<root>    
    <subroot id="11111">
        <ccc>11</ccc>
        <ddd>2005-08-26</ddd>
        <eee>aaaaaaaa</eee>
    </subroot>
    <subroot id="11111">
        <ccc>22</ccc>
        <ddd>2005-08-26</ddd>
        <eee>aaaaaaaa</eee>
    </subroot>
    <subroot id="11111">
        <ccc>11</ccc>
        <ddd>2005-08-26</ddd>
        <eee>aaaaaaaa</eee>
    </subroot>
</root> 

Inside the loop, I need to use  <xsl:key name="ccc" match="subroot" use="ccc"/>. 
But while transforming, I am receiving the following error:

xsl:key is not allowed in this position in the stylesheet!

How do I use "key" tag inside a variable which contains xml?

I appreciate your help.


--- On Fri, 7/25/08, Andrew Welch <andrew.j.welch@xxxxxxxxx> wrote:

> From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
> Subject: Re:  create xml from incoming xml and load it into a variable
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Date: Friday, July 25, 2008, 6:02 AM
> 2008/7/25 sudheshna iyer <sudheshnaiyer@xxxxxxxxx>:
> > How do I create xml from incoming xml and load it into
> a variable from xsl? Afterr loading I
> >
> > have to loop through the variable for doing more xsl
> transformations?
> >
> > My xsl has incoming xml. I have to create another xml
> of different format, put it in a variable
> > and loop through that variable to apply more xsl
> transformations.
> 
> 
> Do the first pass in a variable:
> 
> <xsl:variable name="first-pass">
>   <xsl:apply-templates mode="first-pass"/>
> </xsl:variable>
> 
> The do the second pass by calling apply-templates on the
> first pass:
> 
> <xsl:apply-templates select="$first-pass"/>
> 
> ...or something similar - you may want to mode the second
> pass if it's
> less work.  Remember to have two root match templates, one
> moded, to
> ensure do don't get infinite recursion.
> 
> If the first pass could be a one-off batch process, then
> you're better
> off separating out the transforms than repeatedly doing the
> first pass
> each time.
> 
> -- 
> Andrew Welch
> http://andrewjwelch.com
> Kernow: http://kernowforsaxon.sf.net/

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-2011 All Rights Reserved.