normalize-space and processing-instruction
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 5
- Joined: Tue Jul 31, 2012 1:32 pm
normalize-space and processing-instruction
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
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
-
- Posts: 9421
- Joined: Fri Jul 09, 2004 5:18 pm
Re: normalize-space and processing-instruction
Hi E,
Here's the specification for the normalize-space XSLT function:
https://www.w3.org/TR/xpath-functions/# ... lize-space
Regards,
Radu
Here's the specification for the normalize-space XSLT function:
https://www.w3.org/TR/xpath-functions/# ... lize-space
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.Returns the value of $arg with leading and trailing whitespace removed, and sequences of internal whitespace reduced to a single space character.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9421
- Joined: Fri Jul 09, 2004 5:18 pm
Re: normalize-space and processing-instruction
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
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
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 5
- Joined: Tue Jul 31, 2012 1:32 pm
Re: normalize-space and processing-instruction
No problem on the name front Radu - can I email you the stylesheet on Oxygen XML Editor Support (Radu Coravu) <support@oxygenxml.com> ?
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service