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

Re: xslt replace special characters

Subject: Re: xslt replace special characters
From: "Alice Fan" <arisuu@xxxxxxxxxxx>
Date: Mon, 11 Nov 2002 11:57:03 -0800
xsl replace ampersand
Hi Greg...


I was looking into the '&' problem somemore. What if I used CDATA in my XML file so when its trying to parse it will ignore those special characters. I think this might work. Any ideas on this possible solution?


ALice

From: Greg Faron <gfaron@xxxxxxxxxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  xslt replace special characters
Date: Mon, 11 Nov 2002 11:48:11 -0700

Alice,

It sounds like your user interface is one where the user types in an URL string. You could offer additional fields if they need to enter multiple name/value pairs (the only reason for an ampersand to appear in an URL). Then your xsl could construct the final URL, adding the '?' if any name/value pairs exist, and then outputting them with your own '&amp;' and '=' characters placed between them.

Sample XML (constructed from text fields):
<userURL>
  <baseURL>http://www.someplace.com/dir/page.htm</baseURL>
  <pair>
    <name>arg1</name>
    <value>value1</value>
  </pair>
  <pair>
    <name>arg2</name>
    <value>value2</value>
  </pair>
  <pair>
    <name>arg3</name>
    <value>value3</value>
  </pair>
</userURL>

Relevant XSL:
<xsl:template match="userURL">
  <xsl:value-of select="baseURL"/>
  <xsl:apply-templates select="pair"/>
</xsl:template>
<xsl:template match="pair">
  <xsl:if test="position() = 1">
    <xsl:text>?</xsl:text>
  </xsl:if>
  <xsl:value-of select="name" />
  <xsl:text>=</xsl:text>
  <xsl:value-of select="value" />
  <xsl:if test="position() != last()">
    <xsl:text>&amp;</xsl:text>
  </xsl:if>
</xsl:template>

Greg

At 08:20 PM 11/10/2002, you wrote:
so the user has to input &amp; or &3038; if their url consisys of an '&'.



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


..........................................................
Email: arisuu@xxxxxxxxxxx
Cell: (650) 483-8164
Work: (212) 201-0881
..........................................................r

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail



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.