[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Saxon 9.4 <bold></bold> Transformed to (newline)</bold

Subject: Saxon 9.4 <bold></bold> Transformed to (newline)</bold> Problem
From: Raymond Lillibridge <RLillibridge@xxxxxxxxxxxx>
Date: Tue, 15 Jan 2013 14:14:28 +0000
 Saxon 9.4 <bold></bold> Transformed to (newline)</bold
List members,

Due to some batch processing, some of my input XML may have empty elements.

Here is some sample XML:
<level1>
<para> Here is some text inside a para tag. <bold></bold> Note that the 'bold'
element before the word Note is empty.  I would like it to stay that way
without the insertion of a newline.</para> </level1>


When I transform this XML, using Saxon 9.4, the <bold></bold> element is
getting converted similar to the following:
<level1>
<para> Here is some text inside a para tag.
         <bold/> Note that the 'bold' element before the word Note is empty.
I would like it to stay that way.</para> </level1>


The Problem:
Due to further batch processing needs, I do not want the insertion of a
newline before the <bold/> element, which is being created after running an
XSLT transformation on the sample XML above.  (XMLSpy does not insert the
newline, by the way, but I want to use Saxon for my transformation.)  In my
xsl file I do not have an explicit template match for the 'bold' element.

My XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:mcc="http://www.municode.com/xslt">

<xsl:strip-space elements="*" />
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<!-- To Get:  {$InputDocPath} -->
<xsl:include href="./MCC_LIB.xsl"/>

<xsl:template match="/">
	<xsl:result-document href="{$InputDocPath}/Book_ALL.xml">
		<xsl:apply-templates select="node()" />
	</xsl:result-document>
</xsl:template>

<xsl:template match="book">
		<xsl:element name="book">
			<xsl:element name="bookinfo">
				<xsl:element name="title"></xsl:element>
				<xsl:element name="subtitle"></xsl:element>
			</xsl:element>
			<xsl:apply-templates select="node()"/>
		</xsl:element>
</xsl:template>


<xsl:template match="level1|level2|level3|level4|level5|level6">
	<xsl:copy-of select="./node()" copy-namespaces="no" /> </xsl:template>


<!-- CATCH-ALL ==================================================== -->
	<xsl:template match="@*|node()">
		<xsl:copy-of select="./node()" copy-namespaces="no" />
	</xsl:template>
</xsl:stylesheet>



Looking in the Saxon documentation, I was not able to find a switch to control
the transformation behavior that changes the <bold></bold> to
(newline)<bold/>.

I'd rather not use XMLSpy since all my other batch transformations are using
Saxon.
If there is a configuration switch for Saxon, could someone direct me where I
may learn about it.

Or, would it be more practical to write a template to remove the "empty"
<bold></bold> element, or better yet, remove all empty elements?  I don't know
how this would be written, and would appreciate any insights someone may
offer.


Kind regards,

Raymond Lillibridge
Sr. Software Engineer
rlillibridge@xxxxxxxxxxxx
Municipal Code Corporation | Facebook | Twitter

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.