?
Solved

XSL: retrieve value inside special chars

Posted on 2014-09-11
5
Medium Priority
?
134 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 60

Assisted Solution

by:Geert Bormans
Geert Bormans earned 2000 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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!
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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 …
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…
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

777 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