Page 1 of 1

XSLT - special characters

Posted: Mon Sep 27, 2021 4:56 pm
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!!

Re: XSLT - special characters

Posted: Mon Sep 27, 2021 5:10 pm
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

Re: XSLT - special characters

Posted: Mon Sep 27, 2021 5:13 pm
by jan_suhr
If the XML originates on a Windows machine you might need to encode the XSLT as iso-8859-1

Re: XSLT - special characters

Posted: Tue Sep 28, 2021 9:52 am
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!!

Re: XSLT - special characters

Posted: Tue Sep 28, 2021 10:22 am
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"?>

Re: XSLT - special characters

Posted: Tue Sep 28, 2021 10:36 am
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!

Re: XSLT - special characters

Posted: Tue Sep 28, 2021 2:29 pm
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!!

Re: XSLT - special characters

Posted: Tue Sep 28, 2021 2:35 pm
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.

Re: XSLT - special characters

Posted: Tue Sep 28, 2021 2:40 pm
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!