Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 18th, 2003, 06:28 AM
Registered User
 
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to get Attributes of a element?

Hi i got an problem. i have to read a xml file and using xsl i have to generate another xml file. could you any one please help me in getting a attribute names of a element?

Ex: file1.xml

<ReplyMessage>
   <SubscriberRequest SubscriberID="SDP01" SubscriberPutTimeStamp="" SubscriberTimeZone="" Freshness="11" TrackingNumber="" ApplicationType="ONLINE">
       <DataKey>
         <Data>121</Data>
          .
          .
          .
        </DataKey>
    </SubscriberRequest>
</ReplyMessage>

Output File Should be

<ReplyMessage>
   <SubscriberRequest SubscriberID="SDP01" SubscriberPutTimeStamp="" SubscriberTimeZone="" Freshness="11" TrackingNumber="" ApplicationType="ONLINE">
       <DataKey>
         ....... </DataKey>
</ReplyMessage>

I want the Bold area should disply same in both files!!
Please help me...

Thanks in advance.

Regards,
Srihari

Srihari
 
Old August 18th, 2003, 07:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to armmarti
Default

As I understood, you want just copy all the attributes along with the element "SubscriberRequest" into the output tree.
You can write:
Code:
   ...
   <xsl:template match="SubscriberRequest">
      <xsl:copy>  
        <xsl:copy-of select="@*"/>
        <DataKey>

        </DataKey>
      </xsl:copy>
   </xsl:template> 
   ...
And also I think it'll be better to think of XSLT transformation as a process which deals with tree(s) and which outputs tree(s). The serialization (XML tree -> .xml file, for example) is a separate process, and a transformation souldn't be viewed as outputting the tag "<x>", followed by some text and then the closing tag "</x>".

Regards,
Armen





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem adding element to the previous element dani1 XSLT 5 September 10th, 2008 01:38 AM
translate element name to element name lexzeus XSLT 3 September 4th, 2006 09:04 AM
Attributes and Reflection eadred General .NET 0 July 22nd, 2005 01:53 AM
Count Attributes? btado XSLT 1 January 27th, 2005 02:23 PM
adding of element and assigning to one element sushovandatta XSLT 2 November 16th, 2004 07:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.