This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: Customization layer for address tag
- To: docbook-apps at lists dot oasis-open dot org
- Subject: Re: DOCBOOK-APPS: Customization layer for address tag
- From: Norman Walsh <ndw at nwalsh dot com>
- Date: Tue, 23 Oct 2001 17:55:20 -0400
- List-Id: <docbook-apps.lists.oasis-open.org>
- References: <20011023001546.A555@x8b4e50ae.dhcp.okstate.edu>
/ 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
Country</address>
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 '
' 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. 
 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>
<country>USA</country></address>
Try:
<xsl:template match="legalnotice/address">
<xsl:apply-templates mode="inline-address">
</xsl:template>
<xsl:template match="street|city|postcode" mode="inline-address">
<xsl:apply-templates/>
<xsl:text>, </xsl:text>
</xsl:template>
<xsl:template match="state|country" mode="inline-address">
<xsl:apply-templates/>
</xsl:template>
Untested.
Be seeing you,
norm
--
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
----------------------------------------------------------------
To subscribe or unsubscribe from this elist use the subscription
manager: <http://lists.oasis-open.org/ob/adm.pl>