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]
Other format: [Raw text]

Re: XML apparently cannot be used for general text markup: whitespace gripe


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


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