Subject: [xsl] "(" ")" in xml file causing errors From: Anna Bikkina <anna@xxxxxxxxxxxxxx> Date: Mon, 8 Mar 2004 13:23:43 -0500 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Problem in making an html rep, Munna D | Thread | RE: [xsl] "(" ")" in xml file causi, Andreas L. Delmelle |
RE: [xsl] setting the variable valu, Kotes Mogili | Date | RE: [xsl] "(" ")" in xml file causi, Andreas L. Delmelle |
Month |