Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing dodgy characters with XSL

Status
Not open for further replies.

ahevans

Technical User
Jan 27, 2006
26
GB
Howdy all

I have an XML feed which I apply an XSL sheet to. In the feed some punctuation characters get replaced by a box character, so in my XSL sheet (using Notepad) I have used "translate(job_description,'?SquareCharacter','')" where SquareCharacter is the square character (I cant copy and paste it into this form). Problem is, the square symbol persists. Am I missing a trick?
 
Use wordpad or word or anything supporting unicode to open it.
 
Hi, opened the xsl file in Word and Visual Studio and the square is there, but not in Notepad or EditPadLite. That suggests that the correct character is there to match, but it aint happening. Any ideas?
 
Are you talking about thing in your other previous thread? Why not answering there?
 
previous thread was about repeating data, this is that the translate isnt performing as expected.
 
If my remark in your previous thread stands, (it is terribly confusing to break info half here half ther!), it is this.
[tt] translate(job_description,&#xA156,'')[/tt]
 
Hi

I tried:

<strong>Description; </strong><xsl:value-of select = "translate(job_description,&#xA156,'')" />

And got the message:

A critical error has occurred.
This is an invalid syntax for a hexadecimal numeric entity reference. Line 10, position 91.
 
Like this?

<strong>Description; </strong><xsl:value-of select = "translate(job_description,&#xA156;,'')" />
 
Yes, that's right. My hasty mistake in posting. Should be terminated with semi-colon, of course.
 
If you have this sort of lines in your xml under [tt]nhs_search/vacancy_details[/tt]:

[tt] <job_description>do &#xA156; something &#xA156; useless</job_description>[/tt]
Then your translate line would be this, with apos to make the full amendment to my post previously.

[tt] <xsl:value-of select = "translate(job_description,[red]'&#xA156;'[/red],'')" />[/tt]

Ref also back to my posting in the related thread of the op.
 
i'm wondering if I have the right character as the squares still persist. i need to look for a list of hexadecimal values.
 
Cut and paste a line of job_description. Let me tell you what it is.
 
HI

My current XSL is;

<strong>Description; </strong><xsl:value-of select = "translate(job_description,'&#xA156;','')" />

In the XML, I get a square which I can't copy into this form.
 
Open the xml file (which is just a text file) using word/wordpad/open-office-word/VIM or alike. You should be then able to copy-and-paste from there.
 
okey dokey

i viewed the xml in IE and looked at the source, and the offending character which is causing the squares is a ’

so i did this;

<strong>Description; </strong><xsl:value-of select = "translate(job_description,'’','&#8217;')" />

But the squares are still there in my output. So do I need the hexadecimal for a ’ in the first set of quotes?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top