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 6th, 2004, 11:23 AM
IvanE IvanE is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 98 IvanE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 19 m 38 sec
Reputation Power: 5
Question xsl:character-map problem

Hello there,

I have a problem that I can't seem to get working. Basically I have an attribute in my xml that I want to leave as it is and every way I try it, it is being transformed i.e I have a '>' value and its being transformed into '>'.

So I am trying to get an example working as simple as possible and work from there.

My xml is this,

<?xml version="1.0" encoding="UTF-8"?>
<test><![CDATA[>]]></test>

and then in my xsl I have this,

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xslutput encoding="UTF-8" indent="yes" method="xml" cdata-section-elements="test" />

<xsl:character-map name="test">
<xslutput-character character=">" string=">"/>
</xsl:character-map>

<xslutput use-character-maps="test"/>

........

<xsl:attribute name="alt">
<xsl:value-of select="test"/>
</xsl:attribute>

.....

Every way I have tried it and I have tried it with
<xslutput use-character-maps="test"/>

above the other character code and have tried taking the CDATA out and just using the '>' on its own. But every way I try I keep ending up with
alt=">"
in the outputted html.

What am I doing wrong?

Thanks Ivan.

Reply With Quote
  #2  
Old August 6th, 2004, 12:05 PM
eknock eknock is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: usa
Posts: 4 eknock User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to eknock Send a message via Yahoo to eknock
Arrow Try Decimal Code instead of HTML tags

Try putting the Decimal Code equivalent for ">". A good source is at http://www.natural-innovations.com/wa/doc-charset.html. Hope it helps.

Reply With Quote
  #3  
Old August 9th, 2004, 04:14 AM
IvanE IvanE is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 98 IvanE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 19 m 38 sec
Reputation Power: 5
Quote:
Originally Posted by eknock
Try putting the Decimal Code equivalent for ">". A good source is at http://www.natural-innovations.com/wa/doc-charset.html. Hope it helps.


Thanks for that but I am still not getting it to work. I used the Decimal Code of '>' for the '>' character and it still gave me '&gt' in the html. I am not sure I will be able to change the xml anyway but I am just trying to see why its not working at the moment. I tried using in the xsl also but still no luck.

Reply With Quote
  #4  
Old August 9th, 2004, 01:56 PM
flavist flavist is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 2 flavist User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Try <xsl:value-of select="test" disable-output-escaping="yes"/>

You would still have problems if you are transforming TO an xml format unless you are putting that value into another cdta.

Reply With Quote
  #5  
Old August 11th, 2004, 04:28 AM
IvanE IvanE is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 98 IvanE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 19 m 38 sec
Reputation Power: 5
The problem there flavist is that it is an attribute and xsl does not allow you to disable-output-escaping or doe attributes. That's why I am looking for an alternative way.

On research, I am not sure it can be done. It seems the purists out there say that this is bad use of xml coding and that the design is all wrong if cases like that are encountered.

Because it is only an 'alt' value its not so bad and there might be a possibility of getting the '>' value changed to something else.

I believe it can be done though using processor specific code like saxon:disabe-output-escaping. But I don't want to be processor specific just yet even though I am using saxon.

There are other text nodes that I have html code inside the xml and I can output them to the xsl without escaping using the CData and then output from the xsl to the html without escaping by using the doe. Just attributes that cause the problem.

Reply With Quote
  #6  
Old August 11th, 2004, 10:54 AM
flavist flavist is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 2 flavist User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I guess your options are to re-design the output so that the value can be expressed outside of an attribute (or use a different char) or use the saxon:doe If you know you can continue using Saxon and want to close out the project, I would use that and just document it. The redesign options are better but more work.

Reply With Quote
  #7  
Old August 11th, 2004, 12:27 PM
IvanE IvanE is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 98 IvanE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 19 m 38 sec
Reputation Power: 5
Thanks for your input flavist. The redesign probably is the best option but this is a case study & the original html code exists in a certain way. Whether the xml can be redesigned is not something I am clear on now but the best I can do at the moment is highlight it and leave it the way it is. I am just using Saxon at the moment for no other reason than its there so pinning the code to it would just be a bad option at this time.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > xsl:character-map problem


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


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





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