|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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"> <xsl utput encoding="UTF-8" indent="yes" method="xml" cdata-section-elements="test" /><xsl:character-map name="test"> <xsl utput-character character=">" string=">"/></xsl:character-map> <xsl utput 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 <xsl utput 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. |
|
#2
|
|||
|
|||
|
Try putting the Decimal Code equivalent for ">". A good source is at http://www.natural-innovations.com/wa/doc-charset.html. Hope it helps.
|
|
#3
|
|||
|
|||
|
Quote:
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 '>' 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. |
|
#4
|
|||
|
|||
|
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. |
|
#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. |
|
#6
|
|||
|
|||
|
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.
|
|
#7
|
|||
|
|||
|
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.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > xsl:character-map problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|