XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 19th, 2004, 08:23 AM
awilliford awilliford is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 2 awilliford User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Error when applying stylesheet to xml with & character

I am a newbie to XML/XSL and I was hoping someone could help.

I am retrieving records from the database that could contain the & character and creating an xml document from the records returned. When trying to apply a styelsheet to this xml I get an error when finding an & in the string. For example here is the xml:

<data>
<row>
<col>3902222</col>
<col>FAIRVIEW & COLLINS</col>
</row>
</data>

And here is the select in the xsl:
<xsl:for-each select="col">
<TD valign="top">
<xsl:choose>
<xsl:when test="position() = 1">
<A href="displayData.jsp">
<b>
<xsl:value-of select="."/>
</b>
<BR/>
</A>
</xsl:when>
<xsltherwise>
<xsl:value-of select="." />
<BR/>
</xsltherwise>
</xsl:choose>
</FONT>
</TD>
</xsl:for-each>
</TR>
</xsl:for-each>


Here is the error:
javax.servlet.jsp.JspException: Error applying stylesheet output.xsl Expected name instead of .

I have tried disable-output-escaping = "yes" and that does not work.

Can someone help?
Thanks.

Reply With Quote
  #2  
Old August 19th, 2004, 09:19 AM
rguilbault rguilbault is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 30 rguilbault User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 15 m 18 sec
Reputation Power: 5
Hello. You need to use the entity & in place of & and < in place of "<" when transforming XML...how are you retrieving your records?

Is it possible to 'cleanse' the data string before enclosing it in the <col> tag? (i.e. replace & refrences with & and < with <)

Reply With Quote
  #3  
Old August 19th, 2004, 10:04 AM
awilliford awilliford is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 2 awilliford User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your reply.
I am retrieving the records via jdbc/sql. I have tried to replace the & dynamically while retrieving the records with something else, and the change is reflected in the xml, but I still get the error when applying the stylesheet.

-AW

Quote:
Originally Posted by rguilbault
Hello. You need to use the entity & in place of & and < in place of "<" when transforming XML...how are you retrieving your records?

Is it possible to 'cleanse' the data string before enclosing it in the <col> tag? (i.e. replace & refrences with & and < with <)

Reply With Quote
  #4  
Old August 19th, 2004, 04:44 PM
rguilbault rguilbault is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 30 rguilbault User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 15 m 18 sec
Reputation Power: 5
can you include the whole XSL file? and a sample XML file (is data the root node?)

Something you could try would be to escape the <col> text by wrapping a CDATA around it, i.e.:

<col><![CDATA[ FAIRVIEW & COLLINS ]]></col>

this will also allow you to specify HTML which will be spit out to the browser (rather than being interpretted as XML).

Reply With Quote
  #5  
Old August 19th, 2004, 05:21 PM
NotGoddess's Avatar
NotGoddess NotGoddess is offline
Kung-fu Kitty
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 350 NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 6 h 9 m 2 sec
Reputation Power: 10
Send a message via AIM to NotGoddess
True, but if he can wrap the data in CDATA tags, he could just do & instead of &, correct?

Do you have any control over the base xml document? If you do that is, of course, the best/easiest solution. The xml translator replaces entity values in the xml prior to applying the stylesheet (if any), so I don't believe an xsl solution is possible. (given: I've been wrong before and would welcome a learning experience).

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Error when applying stylesheet to xml with & character


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT