• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in XML parsing and XSLT

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to transform one XML into another xml. The input xml has ' in it (eg : BUDDY'S LANE ). I first parse the XML and then transform it. In this process ' is being replaced with '. But I would like to retain '. Could someone guide me as what needs to be done.

I am using xslt 1.0

Regards,
Premlatha
 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure exactly what you want. Do you want the single-quote to be converted to a single-quote followed by a period? Are you losing the single quote? Maybe if you provide a code sample of the template that processes the element in question along with a small snip of the actual output it would be more clear what the problem is.
 
Latha setty
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
H,

Looks like browser has replaced some of the characters. I am reposting the message here.

I am trying to transform one XML into another xml. The input xml has &apos in it (eg : BUDDY&aposS LANE ). I first parse the XML and then transform it. In this process &apos is being replaced with '. But I would like to retain &apos and not replace it. Could someone guide me as what needs to be done.

I am using xslt 1.0

Regards,
Latha
 
Latha setty
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
H,

Looks like browser has replaced some of the characters. I am reposting the message here.

I am trying to transform one XML into another xml. The input xml has & apos in it (eg : BUDDY&aposS LANE ). I first parse the XML and then transform it. In this process & apos is being replaced with '. But I would like to retain & apos and not replace it. Could someone guide me as what needs to be done.

I am using xslt 1.0

Regards,
Latha
 
Ranch Hand
Posts: 290
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Premlatha,

Try setting this parameter to true:
disable-output-escaping

This is set for xsl:text and valid for xml-2-xml transformation.

So if you use <xsl uput method="text"> it will also help.

Hope this helps
Ahmad
 
Latha setty
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ahmad,

Thanks for the response. I am using xsl:copy-of function and the disable-output-escaping cannot be using with copy-of. Is there any way we can use copy-of and disable-output-escaping together?

Regards,
Latha
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by premlatha:
Is there any way we can use copy-of and disable-output-escaping together?

No, there isn't, because it wouldn't make any difference. But that is all right, because disable-output-escaping would not have solved your problem anyway.

By the way, exactly why is that a problem? The XML that you are getting is well-formed, and it is exactly equivalent to the slightly different XML you say you want. All XML parsers will treat them as if they were exactly the same.

Where does this non-XML requirement come from?
 
Latha setty
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

The output XML will be sent to one of our clients and they want to see ' as & apos.

I came across a xslt function called replace (it is introduced on XSLT 2.0). I tried to use this function for my requirement but to no avail. Any other ideas?

Regards,
Latha
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Premlatha, you may not have noticed when you signed up that the Ranch has a policy on the screen name you choose. In particular, it must be at least two names separated by spaces. Could you please change your name to follow this policy?
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi hemalatha,

it would be good if your content contains &pos; instead of &pos;.
orelse use
<xsl:value-of disable-output-escaping='yes' select="."/>

while retriving content from the xml.

set ur output as
<!-- directly set output encoding to UTF-8 -->
<xsl utput method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

instead of ISO-8859-1

Regards,

Praveen
 
reply
    Bookmark Topic Watch Topic
  • New Topic