Solved

XSL: retrieve value inside special chars

Posted on 2014-09-11
5
129 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
ID: 40317387
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
ID: 40317604
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
ID: 40317711
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
ID: 40320300
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
ID: 40320608
welcome
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

932 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

11 Experts available now in Live!

Get 1:1 Help Now