XSLT - special characters

Post Reply
w.bromley
Member
Posts: 28
Joined: Tue Sep 07, 2021 12:09 pm

XSLT - special characters

Post by w.bromley »

Hi Guys!

I have replaced Andy Bonsey here and as such I need to maintain his workflows. I have run into an issue with the XSLT Transform tool - which seems to glitch out when the character "é" is translated into "é".

Has anyone experienced this kind of think before? I have pinned it down to the XSLT Transform tool by adding loads of holds and stepping through the flow and im 99% sure its down to that element.

Any thoughts at all?

Thanks in advance!!
r.zegwaard
Member
Posts: 93
Joined: Fri Jul 08, 2011 10:31 am
Location: The Netherlands

Re: XSLT - special characters

Post by r.zegwaard »

Hi

Sounds like an encoding issue.
Maybe you can play around with some different encoding-settings in the xslt or in de xml?

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
Robert
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: XSLT - special characters

Post by jan_suhr »

If the XML originates on a Windows machine you might need to encode the XSLT as iso-8859-1
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
w.bromley
Member
Posts: 28
Joined: Tue Sep 07, 2021 12:09 pm

Re: XSLT - special characters

Post by w.bromley »

I'm not too familiar with how these XML transforms work... I totally understand what you mean about encoding and i'm sure thats the case - but i'm not sure how to fix it! The first few lines of my xsl look like this:

Code: Select all

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/"><xsl:text>"OrderID",
What can I add in there to encode it in a different way?

EDIT: I have tried to add the header bits in as per Robert's suggestion but it didnt seem to do anything at all...

Thanks in advance!!
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: XSLT - special characters

Post by freddyp »

It is the definition of the encoding of the input XML that is important. That is what tells the XSLT processor how to interpret the incoming XML.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
The default is UTF-8, so that is what will be used when the declaration line is missing. But if it is not UTF-8 you will have to have a declaration line with the correct encoding. What that correct encoding is I cannot tell for sure, but as Jan suggested it might be iso-8859-1 in which case the declaration line has to be this:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
w.bromley
Member
Posts: 28
Joined: Tue Sep 07, 2021 12:09 pm

Re: XSLT - special characters

Post by w.bromley »

Hi! Thanks for your reply!

I have tried a few different encodings but it doesnt seem to be making a difference - do you know if there is a way I can find out specifically what encoding I need to use?

Thanks in advance!
w.bromley
Member
Posts: 28
Joined: Tue Sep 07, 2021 12:09 pm

Re: XSLT - special characters

Post by w.bromley »

I have been digging into this and it seems you can use Sublime text to show the current encoding of a file.

I have done this to the file in question - and it appears to be <?xml version="1.0" encoding="windows-1252"?>. I have replaced the other encoding line in the XSL - but it sends the job to the problem folder - "Message: Can't parse XSLT stylesheet 'C:/Users/switch/xxx'

Any ideas at all?!

Thanks!!
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: XSLT - special characters

Post by jan_suhr »

XML Transform is not a good tool, it is outdated. And it probably don't understand "windows-1252"

You should use Saxonica instead, it is up to date and can use XSLT 2.0 and 3.0. XML Transform only support XSLT 1.0

There is a free version of Saxonica that you download and then connect it to the Saxonica configurator.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
w.bromley
Member
Posts: 28
Joined: Tue Sep 07, 2021 12:09 pm

Re: XSLT - special characters

Post by w.bromley »

Yeah I think at this point I have all my encoding lined up as it should - its just outdated.

Thanks for the suggestion - I will take a look!
Post Reply