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

an xsl transformation is missing an element from its

Subject: an xsl transformation is missing an element from its output
From: "Tony Zanella" <tony.zanella@xxxxxxxxx>
Date: Tue, 27 May 2008 14:32:42 -0400
 an xsl transformation is missing an element from its
xsl processor: Saxon 8B
xsl version 2.0

This is my first attempt at using xsl to transform xml. Here is my input file:

<?xml version="1.0" encoding="UTF-8"?>
<test>
   <div1>
       <ptr target="a" n="2"/>
       <ptr target="b" n="15"/>
   </div1>
   <div1>
       <ptr target="c" n="72"/>
       <ptr target="d" n="3822"/>
       <ptr target="e" n="3823"/>
   </div1>
</test>


Here is my stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
   <xsl:output method="xml" indent="no" encoding="utf-8" media-type="text/xml"
       doctype-public="-//TEI P4//DTD Main Document Type//EN"/>

   <xsl:template match="@*|node()">
       <xsl:copy>
           <xsl:apply-templates select="@*|node()"/>
       </xsl:copy>
   </xsl:template>


   <xsl:template match="div1">
       <xsl:for-each select="ptr">
           <xsl:element name="ptr">
               <xsl:attribute name="target" select="@target"/>
               <xsl:attribute name="n" select="position()"/>
           </xsl:element>
           </xsl:for-each>
</xsl:template>

</xsl:stylesheet>


When I run the transformation, here is the output I get:

<?xml version="1.0" encoding="utf-8"?><test>
   <ptr target="a" n="1"/><ptr target="b" n="2"/>
   <ptr target="c" n="1"/><ptr target="d" n="2"/><ptr target="e" n="3"/>
</test>

All attributes within the ptr element are exactly as I want them. But
I also want to preserve the div1 element tags in the output. Why are
they not showing up, and how can I get the desired result?

Thanks!
Tony Z.

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.