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

Subject: RE: [xsl] Where's a basic "boiler-plate" xslt for <em>, <strong>, etc. in XML -> XHTML?
From: "Scott Trenda" <Scott.Trenda@xxxxxxxx>
Date: Fri, 28 Sep 2007 16:32:52 -0500
... You're welcome?

Glad to help out. At least the quirks and shortcuts learned from
hours/days/weeks of refactoring haven't gone to waste. ^_^

~ Scott


-----Original Message-----
From: Roger Sperberg [mailto:rsperberg@xxxxxxxxx]
Sent: Friday, September 28, 2007 4:25 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Where's a basic "boiler-plate" xslt for <em>,
<strong>, etc. in XML -> XHTML?

Scott,

Just wanted to say that I read your reply to this query and was really
taken by how simply and clearly you answered it.

Great job. I'm not sure what I'm thanking you for, but I feel I just
have to say thanks.

I'm glad to be able to add someone to my pantheon of clear explicators
(Jeni, Wendell) on this list.

Best regards,

Roger Sperberg
--
rsperberg@xxxxxxxxx




----- Original Message ----
From: Scott Trenda <Scott.Trenda@xxxxxxxx>
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Sent: Friday, September 28, 2007 5:03:15 PM
Subject: RE: [xsl] Where's a basic "boiler-plate" xslt for <em>,
<strong>, etc. in XML -> XHTML?

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


-----Original Message-----
From: Bill Powell [mailto:junk@xxxxxxxxxxxxxxxxxxxxx]
Sent: Friday, September 28, 2007 3:50 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Where's a basic "boiler-plate" xslt for <em>, <strong>,
etc. in XML -> XHTML?

Hi all,

I've just gotten into XML and XSLT and I'm excited, but
after a few tutorials and browsing around sample XSLT sites,
I have a question: does anyone know of a simple XSLT
anywhere that simply translates HTML tags in an XML file
into XHTML?

For instance, if an XML file includes:

<sect1>Heading 1</sect1>
    <p>Some <strong>bold</strong> text. And
<em>emphasized</em> text too.</p>
    <sect2>Heading 2</sect2>
        <p>More <em>emphasized</em> text.</p>

Is there a simple XSLT out there that _just_ translates
<sect1> and <sect2> into <h1> and <h2>, <p> into <p>, <em>
into <em>, _no matter what node it's in?_

I'm thinking y'all might be laughing, but really it doesn't
seem so simple to me. Yet. ;)

I'd like to start using XML for my blog, and I'm excited
about the nifty stuff I can do with categories and such, but
first I need to be able to get the basic posts (tidied into
XML) translating easily into HTML.

This might sound a lot like DocBook; it is, I'm basically
shooting for a very minimalist version of DocBook that won't
take 10 minutes to regenerate my site (and a half hour to
customize; for me, anyhow).

Thanks in advance,
Bill Powell

--
_______________________________________

Adventures of an Ex-Suburbanite
www.billpowellisalive.com

_______________________________________

Current Thread