|
Subject: [xsl] 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 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Come Speak at Balisage (still, B Tommie Usdin | Thread | Re: [xsl] an xsl transformation is , Wendell Piez |
| Re: [xsl] Output sorted XHTML table, Steven Davies | Date | Re: [xsl] Sorting by date, sudheshna iyer |
| Month |