View Single Post
  #3 (permalink)  
Old March 20th, 2008, 10:54 AM
mhkay's Avatar
mhkay mhkay is offline
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

The way to create a new element is like this:

  <xsl:template match="/Root">
      <xsl:value-of select="."/>

You need to understand a very basic concept in XSLT: a stylesheet doesn't generate a file containing lexical markup, it generates a tree containing nodes, which is then passed to a serializer to be serialized. The NEWXMLELEMENT element node in this stylesheet gets copied to create a NEWXMLELEMENT node in your result tree, and the serializer takes this element node and produces the angle bracket markup. If you try to generate markup (start and end tags) by hand, it becomes the content of a text node, which the serializer processes by escaping any special characters it finds.

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote