This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: White space control when formatting for ascii text


Rick Anderson wrote:
> sometimes I get extra tabs. I don't know why.

> Is there a way to make the white space more visibile for better
> debugging? 

<xsl:template match="text()">
  <xsl:value-of select="translate(.,'&#9;&#10;','&#x2192;&#x2193;')"/>
</xsl:template>

(affects text nodes reached via xsl:apply-templates, not the ones you
create with xsl:text)

Although this explanation might help even more...

     <field name="SSN" type="varchar2(9)" keytype="NOT NULL">
       <desc>Social Security Number
       </desc>
     </field>

When you do stuff like this, note that the whitespace that is adjacent to
the non-whitespace text is considered part of the same text node. This
whitespace is not in a node by itself. If it were, then your
xsl:strip-space would get rid of it. Before the strip-space takes effect,
you have the following nodes (I'll use \t and \n to represent tabs for
indenting and newline characters, respectively):

|__text '\t'
|__element 'field' in no namespace
     |  \attribute 'name'='SSN'
     |  \attribute 'type'='varchar2(9)'
     |  \attribute 'keytype'='NOT NULL'
     |  \namespace prefix 'xml'='http://www.w3.org/XML/1998/namespace'
     |__text '\n\t\t'
     |__element 'desc' in no namespace
     |    |  \namespace prefix 'xml'='http://www.w3.org/XML/1998/namespace'
     |    |__text 'Social Security Number\n\t\t'
     |__text '\n\t'

xsl:strip-space will get rid of just the text nodes that contain
whitespace only.

If you can't get the whitespace out of your other text nodes by adjusting
the original XML, try using the normalize-space() function, which will
chop off leading and trailing whitespace and condense consecutive
whitespace characters down to a single space character.

   - Mike
____________________________________________________________________
Mike J. Brown, software engineer at         My XML/XSL resources:
webb.net in Denver, Colorado, USA           http://www.skew.org/xml/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]