Solved

XSL: retrieve value inside special chars

Posted on 2014-09-11
5
128 Views
Last Modified: 2014-09-13
I want to retrieve text contained inside the special characters "Â" so that I can store in a variable.
How do I do this?

<Message>Error parsing response. The response was: ÂDISPLAY PROHIBITEDÂ</Message>


I want the variable to hold "DISPLAY PROHIBITED"
0
Comment
Question by:badtz7229
  • 3
  • 2
5 Comments
 
LVL 60

Assisted Solution

by:Geert Bormans
Geert Bormans earned 500 total points
Comment Utility
I have the impression that this happens only once in a Message

    <xsl:template match="Message">
        <xsl:variable name="display" select="substring-before(substring-after(., 'Â'), 'Â')"/>
        <xsl:value-of select="$display"/>
    </xsl:template>

Open in new window


If it happens more in one Message, you will need some recursive processing.
Happy to provide an example in that case
0
 

Author Comment

by:badtz7229
Comment Utility
This works when I run it through debugger in Visual Studios. But for some reason fails when I run the transaction  I use to call this xsl.
It's as though the à isn't recognized.
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
Comment Utility
I was going to warn you about a possible false interpretation of the "Ã"
XML commonly uses UTF-8 as character encoding.
UTF-8 uses 1 or more bytes for unicode characters (only 7 bits or used per byte)
The number of bytes used per character is dynamic and an indication of the numbertof bytes is found in the first byte
UTF-8 can cover the entire unicode spec using this technique
ISO-8859-1 uses always 1 byte (8 bits per byte) limiting this encoding to below 255 characters
WIN-1252 uses always 1 byte (8 bits per byte) limiting this encoding to below 255 characters, this windows encoding has all the ISO-8859-1 characters at the same location, but has some characters in a zone not used by ISO-8859-1
Now, if a tool interpretes an UTF-8 file falsely as being a ISO-8859-1 file (or WIN-1252) it would make two characters out of two bytes where the encoding actually specified this to be one UTF-8 character
If that is the case, you would spot a number of 'Ã' characters in your text

I think this is going on. Your XML does not specify the encoding, which indicates it is the default UTF-8. Visual Studio assumes it is WIN-1252 the windows default, so you see the 'Ã'
You should fix this interpretation by adding the XML encoding and take a different seperator in your substring expression
If you need to know which is the chararcter... send a original source file over
0
 

Author Comment

by:badtz7229
Comment Utility
Ur absolutely right about the false interpretation.
I caught it and used ur solution as well and it worked. Thanks
0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
welcome
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now