OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] Discard leading/trailing whitespace in <title>elements?


On 3/29/05 12:09, "Bob Stayton" <bobs@sagehill.net> wrote:

> There is no easy way to do what you want.  White space in mixed content
> elements is signficant. A validating editor that pretty prints your XML
> should not be inserting those line breaks.

That might be, but <para> is mixed content, too, and leading whitespace
doesn't cause the first para line to be indented.  That led me to think it's
being discarded, and that the same might be doable for <title>.  Since the
whitespace is passed though XSLT, it's presumably an FO processor issue as
you indicate below.

My "validating editor" is vi. :-)

It's easy for me to produce <title>xxx</title> rather than
<title>
 xxx
</title>.  (A simple change to one of my xmlformat rules.)  I was just
curious whether this could be done in XSLT without a lot of messing around.
Seems the answer is no.

Thanks for the responses.


> 
> If the title element only permitted #PCDATA, then you could use the XSLT
> normalize-space() function, which would trim the leading and trailing spaces
> and collapse a sequence of spaces to single space.  But title permits other
> elements too, and normalize-space() would convert those elements to strings.
> 
> So you would have to write a customization that detects the first node of a
> title, check to see if it is a text() node, and then use the string
> functions to trim any leading linefeed character &#10; .  Same with the
> trailing character of the last node of title. You can't just use
> normalize-space() on those nodes, because the space on the other end of the
> text() node is probably signficant.
> 
> By the way, those line feeds in <para> actually are passed through the XSLT
> processor.  Take a look at your HTML or FO output. I think the line building
> algorithms in the browser and the XSLFO processors don't display them.
> 
> Bob Stayton
> Sagehill Enterprises
> DocBook Consulting
> bobs@sagehill.net
> 
> 
> ----- Original Message -----
> From: "Paul DuBois" <paul@kitebird.com>
> To: <docbook-apps@lists.oasis-open.org>
> Sent: Tuesday, March 29, 2005 8:05 AM
> Subject: [docbook-apps] Discard leading/trailing whitespace in <title>
> elements?
> 
> 
>> I'm using DocBook XSL with FOP to generate PDF.
>> 
>> With a <title> like this:
>> 
>> <title>My Title</title>
>> 
>> The output looks like this:
>> 
>> Section X.Y "My Title"
>> 
>> With a <title> like this:
>> 
>> <title>
>>  My Title
>> </title>
>> 
>> The output looks like this, with a space between the quote characters
>> and the title content:
>> 
>> Section X.Y " My Title "
>> 
>> 
>> This retention of surrounding whitespace around element content does
>> not occur for elements such as <para>. Is there something I can do
>> to cause surrounding whitespace to be discarded for <title> elements
>> as well.
>> 
>> 
>> 
>> 
> 
> 




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]