normalize-space and processing-instruction

Here should go questions about transforming XML with XSLT and FOP.
eb621
Posts: 5
Joined: Tue Jul 31, 2012 1:32 pm

normalize-space and processing-instruction

Post 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
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: normalize-space and processing-instruction

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
eb621
Posts: 5
Joined: Tue Jul 31, 2012 1:32 pm

Re: normalize-space and processing-instruction

Post 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
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: normalize-space and processing-instruction

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
eb621
Posts: 5
Joined: Tue Jul 31, 2012 1:32 pm

Re: normalize-space and processing-instruction

Post 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> ?
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: normalize-space and processing-instruction

Post by Radu »

Hi,

Sure, we'll discuss via email.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply