[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

"(" ")" in xml file causing errors

Subject: "(" ")" in xml file causing errors
From: Anna Bikkina <anna@xxxxxxxxxxxxxx>
Date: Mon, 8 Mar 2004 13:23:43 -0500
xml to xls
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.