This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: XML apparently cannot be used for general text markup: whitespace gripe
- From: "Chad Jones" <chad at avatarsoft dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 19 Mar 2002 22:01:57 +0200
- Subject: Re: [xsl] XML apparently cannot be used for general text markup: whitespace gripe
- References: <5.1.0.14.0.20020319130911.02a565d0@messagerie.jouy.4dconcept.fr>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Paul,
> XML has a rule : multiple adjacent whitespaces or linefeeds are
> non-significant. However, you can change this behavior, by adding the
> 'xml:space' attribute on a node with the 'preserve' value, in the DTD,
like
> this :
>
> <!ATTLIST listing xml:space (default|preserve) 'preserve'>
This is exactly what I'm after since the HTML presentation will normalize
any additional whitespace. Actually I would prefer an XSL solution but,
since I have control of the DTD, this works for me.
Ok, one problem with implementation:
This works:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="whitespace.xsl"?>
<book>
<par xml:space='preserve'>Is his name really <first>John</first>
<last>Doe</last>?</par>
</book>
But when I put the xml:space attribute in the DTD, it no longer works. Here
is an example:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="whitespace.xsl"?>
<!DOCTYPE book [
<!ELEMENT book (par+)>
<!ELEMENT par (#PCDATA|first|last)*>
<!ATTLIST par xml:space (default|preserve) 'preserve'>
]>
<book>
<par>Is his name really <first>John</first> <last>Doe</last>?</par>
</book>
Any suggestions?
- Chad
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list