I am using Saxon9 on Windows
Here's my problem
I am given an XML document that is formatted such as:
Code:
<A>
<B>
<C>xyzzy</C>
<D>
...
</D>
</B>
<B>
<C> </C>
<D>
...
</D>
</B>
<B>
<C></C>
<D>
...
</D>
</B>
<B>
<C>abc 123</C>
</B>
</A>
My job is to translate this to another XML format that is basically the same structure, but different tags. No problem.
Later they come back a want me to only translate the 'C' tags if there is meaningful data in them. So the blank one and the one with only a whitespace need to be left out of the result.
So the result would look like:
Code:
<A>
<B>
<C>xyzzy</C>
<D>
...
</D>
</B>
<B>
<!-- dropped the C with whitespace content -->
<D>
...
</D>
</B>
<B>
<!-- dropped the C with empty content -->
<D>
...
</D>
</B>
<B>
<C>abc 123</C>
</B>
</A>
I've tried various analyze-string regex's, but they are not giving me the result I'm after.
<xsl:analyze-string select="string()" regex="^[\S*]$">
seemed like a good place to start, if there is a non-whitespace character anywhere in the string, then copy it to the result.
Does anyone have any suggestions?
Thanks!