Solved

XSL: retrieve value inside special chars

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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!
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.
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
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…

696 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