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

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

Subject: RE: Saxon 9.4 <bold></bold> Transformed to (newline)</bold> Problem
From: Raymond Lillibridge <RLillibridge@xxxxxxxxxxxx>
Date: Tue, 15 Jan 2013 17:30:31 +0000
RE:  Saxon 9.4 <bold></bold> Transformed to  (newline)<
Mr. Kay,

Thank you for your wealth of information!  First in your reply (below) and
also for your books.

Since the addition of the indent="no" did not correct the problem, I'm going
to do some data checking.  We've been using Saxon-EE 9.4 for quite some time
and it's been wonderful.  It just may be that there is something wrong with
the data.

Transforming <bold></bold> to </bold> is quite alright.

After some data checking and then some more XSLT testing, I'll keep the list
updated about my solution, &c.


Kind regards,

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



-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: Tuesday, January 15, 2013 12:04 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Saxon 9.4 <bold></bold> Transformed to (newline)</bold>
Problem

There are several ways you could fix this problem.

First, you could switch indentation off entirely (indent="no").

Secondly, you could use schema-awareness on the output side (that is, validate
the output against a schema). If you do this, Saxon will not add whitespace
within an element that has a mixed-content content model.
Validation of course needs Saxon-EE.

Thirdly, you could use the suppress-indentation xsl:output parameter.
This was introduced as a Saxon extension (saxon:suppress-indentation) and has
found its way into the XSLT 3.0 specification. Either way, you will need
Saxon-PE or higher.

Note that the fact that the bold element is empty has nothing to do with it;
the indentation will occur for any start tag unless it is suppressed.

I assume that you're not complaining about the translation of <bold></bold> to
<bold/>?

Michael Kay
Saxonica


On 15/01/2013 14:14, Raymond Lillibridge wrote:
> 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.