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

Re: Adding element to xml snippet using xslt

Subject: Re: Adding element to xml snippet using xslt
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 23 Feb 2005 00:13:42 GMT
xslt select element
   I was able to tackle the 'drillOutDir' node in the following way --
   <xsl:template match="abc:configuration">
     <xsl:element name="drillOutDir">
      <xsl:value-of select="abc:configuration/drillOutDir"/>
    </xsl:element>      
   </xsl:template>

   This results in the correct output xml doc ie

so you have abc:configuration elements that are children of
abc:configuration elements?


   This results in the correct output xml doc ie
   <abc:configuration>
   <drillOutDir></drillOutDir>
   </abc:configuration>

do you really want emoty drilloutdir element here, or is that just empty
as the answer to the above question is no, in which case
      <xsl:value-of select="abc:configuration/drillOutDir"/>
will never generate ay text.

   Now the only issue remaining is for the 'started' element node, which is 
   at the same level as the 'drillOutDir' node but apparently needs to be 
   merged using xslt.

I have no idea what you mean by that.


   ie I can insert the following in the above template
    <xsl:element name="started">
             <xsl:attribute 
   name="status"><xsl:text>true</xsl:text></xsl:attribute>
      </xsl:element>


You could insert 
 <started status="true"/>
which is equivalent but easier to type.


  But I do not want to hardcode the value of the attribute status in my 
   xslt. I would like to get it using the value of or something expression. 
   Apparently when I use the value-of or any other copy-of select clause, I 
   only get an empty 'started' node.
      <xsl:copy-of select="@status[. = 'true' ]"/>
      <xsl:value-of select="abc:configuration/started"/>
   
   How can I resolve this part?

The xpath has to match your input.

      <xsl:copy-of select="@status[. = 'true' ]"/>
I don't know what you want this to do, but it just copies an attribute
node if it is of the form status="true" so it is more or less the same
as just hard coding that attribute into the template. (except it does
nothing if the attribute isn't in the source)

      <xsl:value-of select="abc:configuration/started"/>
If you are putting this in the template matching  abc:configuration
then your current node is abc:configuration so unless that element has a
child of the same name, this will select nothing (which is the same
question as I asked at the start). If started is a child of the current
node you want
      <xsl:value-of select="started"/>
if you just want the text or

      <xsl:copy-of select="started"/>
if you want a copy of the element.

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.