xsl-list
[Top] [All Lists]

RE: [xsl] Re: Where's a basic "boiler-plate" xslt for <em>, <strong>, etc. in XML -> XHTML?

2007-09-28 14:30:16
Much obliged. ^_^

Also, I'm not sure what the native <xsl:preserve-space/> elements are
under <xsl:output method="html"/>, especially with MSXML being so
vicious with input whitespace, but for most purposes, the processor
knows what to do and how to do it correctly.

Just make sure to run it through a few tests to make sure it's doing
everything you expect it to. Best of luck to you!

~ Scott


-----Original Message-----
From: Bill Powell [mailto:junk(_at_)billpowellisalive(_dot_)com] 
Sent: Friday, September 28, 2007 4:23 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Re: Where's a basic "boiler-plate" xslt for <em>,
<strong>, etc. in XML -> XHTML?

I cannot believe I just called you Steve.

Sorry, Scott. [blush]

It is true that I'm working on a script right now starring a
character named Steve, so perhaps that's an extenuating
circumstance. But still. One does feel foolish.

Thanks again. :)

Bill

+++ Bill Powell [28/09/07 17:20 -0400]:
Steve - Wonderful! Thanks very much! This is just the sort
of thing that can slip through the cracks; much appreciated.
I went to the #xml channel on irc.freenode.net, and the only
one who answered was having the same problem. I'm going to
post this on my blog with as many searchable terms as I can
think of, as well as a link to the archived thread.

Thanks again!
Bill Powell


+++ Scott Trenda [28/09/07 16:03 -0500]:
Bill - 

XSLT handles HTML output beautifully natively. I'm guessing that
you'll
want something like the following: (I'm not sure what all of your
non-HTML tags are, so just take the pattern from the sect1
template:)

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output method="html"/>

  <!-- This will handle any nodes we don't explicitly define
templates
for.
       It copies the source as-is, and xsl:output handles the HTML
format.  -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <!-- sect1 means h1 -->
  <xsl:template match="sect1">
    <h1>
      <xsl:apply-templates select="@*|node()"/>
    </h1>
  </xsl:template>

</xsl:stylesheet>


And that's it. Basically, the XSLT processor knows how to handle the
formatting differences between XML and HTML, so we use <xsl:output
method="html"/> to put it into that mode. The first template is a
basic
"copy everything" template, and after that, just set up a series of
templates to intercept nodes that need to be renamed or reformatted.

Simple enough? ~_^

~ Scott


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


-- 
_______________________________________

Adventures of an Ex-Suburbanite
www.billpowellisalive.com

_______________________________________


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--