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] | [Elist Home]

Subject: Re: DOCBOOK-APPS: Customization layer for address tag

/ Eric Baudais <baudais@okstate.edu> was heard to say:
| I am trying to write a customization layer using the XSL stylesheets for 
| DocBook XML 4.1.2.  It is importing Norm's stylesheets as a basis.  I am 
| trying to alter how the address tag is displayed for HTML.  Currently it is 
| outputing:	<div class="address">Free Software Foundation,Inc. <br>
| 		  	59 Temple Place - Suite 330<br>
| 		  	Boston MA 02111-1307<br>
| 		  	USA<br>
| 			</div>
| I want to have the output look like: 
| 			<div class="address">Free Software Foundation,Inc., 59 Temple Place
| 			- Suite 330, Boston, MA 02111-1307, USA</div>

You could just write the address that way:

<address>Free Software Foundation,Inc., 59 Temple Place
- Suite 330, Boston, MA 02111-1307, USA</address>

The problem you're running into is that <address> has "verbatim" semantics.
So that you can write

<address>Some Street
Some City, Some Province
Postal Code

and have it display that way (rather than getting all run together).

But if you don't want a <pre> (which implies a fixed-width font), the only way
to do this (reliably, CSS notwithstanding) is to replace spaces with non-breaking
spaces and linefeeds with <br/>.

| This leads to the make-verbatim template which is almost a complete mystery.
| I start losing it at the definition of the variable starts-with-nl.  What is 
| the string '&#xA;' supposed to be?

Yeah, it's a pretty hairy template. Basically it recurses to walk over
the content of the address so that it can replace the characters it
needs to. &#xA; is a linefeed.

| Below is the start of the customization of address.
| <xsl:template match="legalnotice/address//text()">
|   <xsl:call-template name="make-verbatim-inline">
|     <xsl:with-param name="text" select="."/>
|   </xsl:call-template>
| </xsl:template>
| <xsl:template name="make-verbatim-inline">
| At this point I'm at a loss of where to continue.  Basically I only want 
| to alter a portion of the template "make-verbatim" so instead of inserting 
| <br/> I insert "," except for the child state.  How do you this?

What does your source markup look like?

Let's assume it's:

<address><street>Free Software Foundation,Inc.<street>
<street>59 Temple Place - Suite 330</street>
<city>Boston</city> <state>MA</state> <postcode>02110-1307</postcode>


<xsl:template match="legalnotice/address">
  <xsl:apply-templates mode="inline-address">

<xsl:template match="street|city|postcode" mode="inline-address">
  <xsl:text>, </xsl:text>

<xsl:template match="state|country" mode="inline-address">


                                        Be seeing you,

Norman Walsh <ndw@nwalsh.com>      | Everything in the universe goes by
http://www.oasis-open.org/docbook/ | indirection. There are no straight
Chair, DocBook Technical Committee | lines.--Emerson

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

Powered by eList eXpress LLC