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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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.

   
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.