XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Manikandan SurendranathSubject: XSLT outputs default attributes and values
Author: Manikandan Surendranath
Date: 06 Apr 2005 12:09 PM
I am writing just to copy an input xml to output xml. Below is my xslt

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
<xsl:output method="xml" encoding="utf-8" indent="yes" />

<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>

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

</xsl:stylesheet>

I expected the output and input xml to be identical but the output xml has additional attributes with the default value specified in DTD. I am aware that xml processor generates these defalut nodes before XSLT processor and therefore XSLT cannot avoid this. I tried removing the DTD reference from the xml before inputting to XSLT, but it gives me error for undeclared entities. Since I am not the owner of the DTD I cannot change the attributes to OPTIONAL. Is there a way to avoid inclusion of default attributes being added to the output xml?

Postnext
Ivan PedruzziSubject: XSLT outputs default attributes and values
Author: Ivan Pedruzzi
Date: 06 Apr 2005 08:58 PM
You could try to add only the DTD section that defines the entities

Ivan

Postnext
Manikandan SurendranathSubject: XSLT outputs default attributes and values
Author: Manikandan Surendranath
Date: 07 Apr 2005 04:37 AM
I will try that, but one more issue using DTD reference is that XSLT replaces named entities with equivalent encoded character. I have an entities &emsp; in input but in the output it was replaced by an emspace character. Can this be avoided?

Posttop
Tony LavinioSubject: XSLT outputs default attributes and values
Author: Tony Lavinio
Date: 07 Apr 2005 09:25 AM
XSLT doesn't know anything about entities, or even default values
for attributes.
The XML parser itself is what parses the XML file, and converts
entities and supplies the default values. This is just the way
XML engines work - the parser builds the data model, applying whatever
it needs to from the DTD. Then the next step, whether it is XSLT
or XQuery or whatever, works on the model. Then, when the engine is
finished, the XML serializer (the inverse of the parser) takes the
result and turns it back into text. XSLT 2.0 does include a mechanism
for instructing the serializer to convert certain Unicode code-points
back into entities; see http://www.w3.org/TR/xslt20/#character-maps
You can use this with Saxon 8, which we support as one of our XQuery
engines.

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.