[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] normalize-space() except ...


Subject: [xsl] normalize-space() except ...
From: "dvint@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 9 Feb 2015 20:21:07 -0000

So I have some mixed content that has a wide variety of whitespace useage
that I need to normalize/simplify because the receiving system is not
ignoring it, even though the input is an XML file. Receiving system is
Open Office Calc using the MS XML Spreadsheet xml format.

For the most part normalize-space is doing the trick until it hits mixed
content. So I have something like this for input:

<dd><p>
         This is my text
with <i>italics content</i> with other text.
</p></dd>

My output is coming out like this:
<ss:Data>This is my text with<ss:font italics="yes">italics
content</ss:font>.</ss:Data>

Which results in "... text withitalics contentwith other text."

My content is simple enough that I can probably check for
following::sibling being certain elements and then just add a space back
in, and then with the content of the <i> element I would have to analyze
the following content and if text() look to see if the first character is
punctuation.

I'm just wondering if there is a better solution for handling this in XSLT
than basically writing my own normalize-space function. The real solution
would be to get the importing tool to handle the text properly and
normalize on import, but that is not an option.

Any suggestions?

..dan


Current Thread
Keywords