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 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
leopaul pradeepSubject: Parsing special characters in XSL
Author: leopaul pradeep
Date: 19 Jan 2010 10:32 AM
Hi,

I have an xml with special charcters in a tag ( eg. abc ; bgh). I've used an xslt (given below) to parse it. I'm getting a value for characteristic, which i'm assigning to characteristic_name and setting it as an attribute name. This works fine, but the problem comes if there is a special character in the characteristic. Bcos when setting it as an attribute name parser throws an error. Pls help me to solve the issue.

Thanks in Advance,
Leo

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<data jsxid="jsxroot">
<xsl:apply-templates select="//Envelope/Body/ItemSearchResponse/body"/>
</data>
</xsl:template>
<xsl:template match="body">
<xsl:for-each select="//body/record">
<record>
<xsl:attribute name="jsxid"><xsl:value-of select="jsxid"/></xsl:attribute>
<xsl:attribute name="PRODUCTID"><xsl:value-of select="productId"/></xsl:attribute>
<xsl:attribute name="PRODUCTDESCRIPTION"><xsl:value-of select="productDescription"/></xsl:attribute>
<xsl:apply-templates select="characteristicDetails"/>
</record>
</xsl:for-each>
</xsl:template>
<xsl:template match="characteristicDetails">
<xsl:variable name="characteristic_name" select="characteristic"/>
<xsl:attribute name="{$characteristic_name}">
<xsl:value-of select="characteristicValue"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>

Posttop
Tony LavinioSubject: Parsing special characters in XSL
Author: Tony Lavinio
Date: 25 Jan 2010 02:17 PM
It's hard to see without the actual incoming XML, which is where you state the problem actually is.

If the incoming XML is invalid, XSLT won't be able to handle it. XSLT doesn't see the XML until the XML parser has parsed it, and if the XML is bad, the parser will stop well before XSLT even knows there is an issue.

 
Topic Page 1 2 3 4 5 6 7 8 9 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.