[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] "(" ")" in xml file causing errors
Hi, I have an xml file which contains data like <result><row> <(expression)>3DO COMPANY</(expression)><(expression)>THDOQ</ (expression)><(expression)>95688</(expression)><(expression)>GVRC2 </ (expression)><(expression)>0.01300 / 0.04000(5000 x 5000)</ (expression)><(expression)> </(expression)><(expression)>02-11</(expression)> </row> </result> I am trying to use this xml to convert it to excel format(I have an xsl file that converts xml to xls format). When used directly it is giving an error "The content of elements must consist of well-formed character data or markup." . I thought it could not because of the "(". Do you think so?. I want to get rid of braces( "(" and ")" from this xml and have another xml with the same data without braces. I am trying to write xsl to do the same but it is not working. Can someone please help. My xsl file <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:template name="replace-string"> <xsl:param name="text"/> <xsl:param name="replace"/> <xsl:param name="with"/> <xsl:choose> <xsl:when test="contains($text,$replace)"> <xsl:value-of select="substring-before($text,$replace)"/> <xsl:value-of select="$with"/> <xsl:call-template name="replace-string"> <xsl:with-param name="text" select="substring-after($text,$replace)"/> <xsl:with-param name="replace" select="$replace"/> <xsl:with-param name="with" select="$with"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="result"> <xsl:variable name="leftBraceReplaced"> <xsl:call-template name="replace-string"> <!-- imported template --> <xsl:with-param name="text" select="." /> <xsl:with-param name="replace" select="'('"/> <xsl:with-param name="with" select="'(('"/> </xsl:call-template> </xsl:variable> <xsl:variable name="bothBracesReplaced"> <xsl:call-template name="replace-string"> <xsl:with-param name="text" select="$leftBraceReplaced"/> <xsl:with-param name="replace" select="')'"/> <xsl:with-param name="with" select="'))'"/> </xsl:call-template> </xsl:variable> <xsl:for-each select="row"> <xsl:for-each select="*"> <xsl:value-of select="$bothBracesReplaced"/> </xsl:for-each> </xsl:for-each> </xsl:template> <xsl:template match="@*|*|text()|processing-instruction()"> <!-- Catch all template. Just pass along unmodified everything we don't handle. --> <xsl:copy> <xsl:apply-templates select="@*|*|text()|processing-instruction()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> Can someone please help . Thanks, Anna. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|