Solved

XSL: retrieve value inside special chars

Posted on 2014-09-11
5
131 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Javascript 2 37
Hiding Adsense on Mobile Devices 2 45
ASP Classic - Read XML File inner content 10 40
XSL for-each loop - Excluding specific text 4 9
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

679 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