[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"?>
       <ptr target="a" n="2"/>
       <ptr target="b" n="15"/>
       <ptr target="c" n="72"/>
       <ptr target="d" n="3822"/>
       <ptr target="e" n="3823"/>

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:apply-templates select="@*|node()"/>

   <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()"/>


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"/>

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?

Tony Z.

Current Thread


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.
First Name
Last Name
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.