[xsl] White space strategies for mixed content

Subject: [xsl] White space strategies for mixed content
From: "Rick Quatro rick@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 5 Nov 2019 00:59:52 -0000
Hi All,

 

I have inherited some "interesting" xml that has mixed content and I am
trying to figure out some strategies for getting "cleaner" output in my XSLT
workflow without removing any needed whitespace. In the simple example
below, I want to normalize the white space and let the serializer write out
the breaks where it wants to.

 

Input:

 

<?xml version="1.0" encoding="UTF-8"?>

<root>

    <para>This is the title element with a

    <emphasis>child</emphasis> element and<strong> another</strong>

    one.</para>

</root>

 

Output:

 

<?xml version="1.0" encoding="UTF-8"?>

<root><para>This is the title element with a <emphasis>child</emphasis>
element and<strong> another</strong> one.</para></root>

 

In this example, I think <xsl:strip-space elements="root"/> would take care
of it with <xsl:output indent="no"/> but of course my actual input is more
complex.

 

I have struggled a bit in my understanding of whitespace handling in XML and
XSLT so I may be missing something obvious. Thanks in advance for any
advice.

 

Rick

 

Rick Quatro

Carmen Publishing Inc.

rick@xxxxxxxxxxxxxxx

585-729-6746

www.frameexpert.com/store/

Current Thread