Page 1 of 1

normalize-space and processing-instruction

Posted: Tue Feb 27, 2018 7:06 pm
by eb621
Hi,

I have some xml with processing instructions and I need to normalize the space and retain the pi. This is the xml

<title>L<?lwrc?>e<?lwrc?> Blanc's blog</title>

When I apply normalize-space the space between the 2nd <?lwrc?> and B goes missing so if I output without the pi I get

<title>LeBlanc's blog</title>

and with

<title>L<?lwrc?>e<?lwrc?>Blanc's blog</title>

I did see somewhere that the pi is counted as a space in certain circumstances which seems to be the case here. I need to normalize as there can/will be spacing elsewhere that needs addressing.

Has anyone any idea how to get 'round this?

Thanks

Re: normalize-space and processing-instruction

Posted: Wed Feb 28, 2018 12:58 pm
by Radu
Hi E,

Here's the specification for the normalize-space XSLT function:

https://www.w3.org/TR/xpath-functions/# ... lize-space
Returns the value of $arg with leading and trailing whitespace removed, and sequences of internal whitespace reduced to a single space character.
so that's what it does, it also removes the trailing and leading spaces. I guess you could first check if there are trailing and leading spaces and if there are, add them back after calling the function.

Regards,
Radu

Re: normalize-space and processing-instruction

Posted: Wed Feb 28, 2018 2:05 pm
by eb621
Hi Radu - blown my cover then...

I've looked at that but it doesn't really help me here as I'm back at it seems to think the pi is a space

Re: normalize-space and processing-instruction

Posted: Wed Feb 28, 2018 2:48 pm
by Radu
Hi,

Sorry for using your actual name, as an admin I can see your email address, I edited my previous post to remove your name reference.
About your problem, seeing more of the XSLT you have might help me understand it better.
Basically when applying XSLT over the <title> element, it has 5 child elements:

- The 'L' text node
- The '<?lwrc?>' PI
- The 'e' text node
- The '<?lwrc?>' PI
- The ' Blanc's blog' text node.
If you apply the normalization on that last text node the normalization will among other things remove the space before it.

Regards,
Radu

Re: normalize-space and processing-instruction

Posted: Wed Feb 28, 2018 2:52 pm
by eb621
No problem on the name front Radu - can I email you the stylesheet on Oxygen XML Editor Support (Radu Coravu) <support@oxygenxml.com> ?

Re: normalize-space and processing-instruction

Posted: Wed Feb 28, 2018 3:03 pm
by Radu
Hi,

Sure, we'll discuss via email.

Regards,
Radu