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

Re: creating top-level elements from within child ele

Subject: Re: creating top-level elements from within child elements
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 22 Feb 2005 15:36:41 GMT
flag boolean email has
  The problem Im facing with this approach is that I do not want A2 to
  appear i n the output xml file unless some condition in the A1
  template is true. This brings me back to the use of a 'flag' boolean
  variable which will check whether its value is 'true' before creating
  A2.

If the test affects the generation of both A1 and A2 the just move it up
to the point that you are generating those elements instead of having it
in the template that's just generating A2. really there is no problem
here.

  However it would be much more efficient to have some feature in XSLT
  which will allow you to position an element outside the template.  

templates are the XSLT mechanism for determing where in the result tree
constructed elements are placed. So I have no idea what you mean here.


> I am not sure how you can create the element <SubConcepts> from within 
> the <PrimeConcept> template match. My present code is

this is just the same as generating any other element.

You (still) have

<xsl:template match="/">
   <Top>
       <PrimeConcept><xsl:apply-templates select="Top/TopNode" 
mode="top"/></PrimeConcept>
   </Top>
</xsl:template>


which is explictly wrapping a PrimeConcept around everything, which is
why everything is coming out as a child of PrimeConcept.


You didn't post your input, so this isn't filled in , but you want
something like:

<xsl:template match="Top">
   <Top>
       <xsl:apply-templates select="TopNode" />
   </Top>
</xsl:template>

<xsl:template match="TopNode">
<PrimeConcept id='10180'>Car</PrimeConcept>
<SubConcepts>
 <SubConcept id='10298'>Toyota</SubConcept>
</SubConcepts>
</xsl:template>


will do the job, but presumably you want to replace some of those fixed
element and attribute names by xpath expressions.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.