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

Losing an attribute in transformation

Subject: Losing an attribute in transformation
From: "Tracey Zellmann" <tracey.zellmann@xxxxxxxxxxx>
Date: Thu, 13 Jul 2006 20:18:34 -0400
xsl apply templates losing attributes
Recently, David Carlisle posted a reply to a question I had about a namespace.

I have made progress using his suggestion, but I appear to have one remaining problem.

I have xml content that includes a span element with a class attribute. After my xsl stylesheet transforms this to html, the attribute has been removed.

Here is an example that demonstrates the issue narrowly.

<?xml version="1.0" encoding="ISO-8859-1"?>
<page seq="1">
<p>Edward Jarvis (1803-1884) was a physician. His manuscript <span class="book-title">Houses and People in Concord, 1810 to 1882</span> contains his recollections of buildings in Concord during his youth.</p>

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
<xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
method="html" indent="yes" encoding="ISO-8859-1" />
<xsl:template match="page">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" >
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<xsl:apply-templates mode="xh" select="content/p" />
<xsl:template match="*" mode="xh">
<xsl:element name="{local-name()}"
<xsl:apply-templates mode="xh" />

Actual output
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></meta>

<p>Edward Jarvis (1803-1884) was a physician. His manuscript <span>Houses and People in Concord, 1810 to 1882</span> contains his recollections of buildings in Concord during his youth.

Everything validates as xhtml strict.
However, I have lost the class="book-title" part of the opening span tag.

How can I retain the attribute?

Any help will be appreciated.

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.