copy root node - urgent

Please support our XML, XSLT and XPATH advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Feb 2009
Posts: 9
Reputation: rat1973 is an unknown quantity at this point 
Solved Threads: 0
rat1973 rat1973 is offline Offline
Newbie Poster

copy root node - urgent

 
0
  #1
Feb 11th, 2009
I really need help in copying the root node.

I have been spending far too much time on this, and I can't beleive that it should be that difficult. I can't use 'copy-of', as that will copy all the children as well. I need to copy the root node, and it's attributes. This is what I currently have:

XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pre="http://schemas.namespace.org/myschema/myschame.xsd">
  3. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  4.  
  5. <xsl:template match="/">
  6. <xsl:element name="{name()}">
  7. <xsl:apply-templates select="pre:Msg" />
  8. </xsl:element>
  9. </xsl:template>
  10.  
  11. <xsl:template match="pre:Msg">
  12.  
  13.  
  14. <xsl:for-each select="pre:Record">
  15.  
  16. <xsl:sort select="pre:ReplaceRecord/pre:Id/pre:Number" />
  17. <xsl:sort select="pre:EventSequenceNumber" data-type="number"/>
  18. <xsl:copy-of select="." />
  19. </xsl:for-each>
  20.  
  21.  
  22. </xsl:template>
  23.  
  24. </xsl:stylesheet>

The above xsl will thow an error. It has something to do with namespaces. The error is:

An attribute whose value must be a QName had the value ''

I have tried using the namespace attribute, plus a heap of other things. All I wish to do is to copy the root node. Can somebody please help me with this. Thankyou.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 9
Reputation: rat1973 is an unknown quantity at this point 
Solved Threads: 0
rat1973 rat1973 is offline Offline
Newbie Poster

Re: copy root node - urgent

 
0
  #2
Feb 11th, 2009
I beleive I have it now. I needed the following:

XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pre="http://schemas.namespace.org/myschema/myschame.xsd">
  3. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  4.  
  5. <xsl:template match="/">
  6. <xsl:apply-templates select="pre:Msg" />
  7. </xsl:template>
  8.  
  9. <xsl:template match="pre:Msg">
  10. <xsl:copy>
  11.  
  12.  
  13. <xsl:for-each select="pre:Record">
  14.  
  15. <xsl:sort select="pre:ReplaceRecord/pre:Id/pre:Number" />
  16. <xsl:sort select="pre:EventSequenceNumber" data-type="number"/>
  17. <xsl:copy-of select="."/>
  18. </xsl:for-each>
  19.  
  20. </xsl:copy>
  21.  
  22. </xsl:template>
  23.  
  24. </xsl:stylesheet>

A case of still learning XSL.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the XML, XSLT and XPATH Forum


Views: 988 | Replies: 1
Thread Tools Search this Thread



Tag cloud for XML, XSLT and XPATH
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC