Re: XSL outputting HTML from an XML source

Subject: Re: XSL outputting HTML from an XML source
From: Warren Hedley <w.hedley@xxxxxxxxxxxxxx>
Date: Fri, 19 May 2000 15:56:20 -0400
Ariel Garza wrote:
> 
> <CONTENT>
> This is a generic piece of content that a content person wants to have
> <B>dynamic bold</B> in.
> </CONTENT>

To get this output, put it straight in your stylesheet.

<xsl:template match="some_element">
  <content>Here's my <b>content</b>.</content>
</xsl:template>

> In other words, Netscape just prints out
> <B>dynamic bold</B> without evaluating the tags.

Huh? If Netscape sees <B>...</B>, the ... should be bold, unless
you have some stylesheet that tells it to do otherwise.

> Is there a way to
> include HTML on the fly, not knowing where in the tree it is and have
> the XSL stylesheet output it as though it were HTML and not text?

First of all you should have an <xsl:output method="html"> at the top
of your stylesheet. This won't actually affect how <B> tags are output
but it will affect things like <br />, which becomes <br>. Any HTML
that you want in your output document you just define in the templates
that are applied to your input document. The following creates your
basic HTML structure. Is this what you meant?

<xsl:template match="/">
  <html>
    <head>
      <title>Hello World!</title>
    </head>
    <body>
      <h1>Hello World!</h1>
    </body>
  </html>
</xsl:template>

> If I
> use straight <B></B> tags in XML, is there a way to have a stylesheet
> interpret all <B></B> tags automatically?

If you have a <b>...</b> in your stylesheet, any working
processor will put a <b>...</b> in your output document.
If you want <b>...</b> in your input XML to become something
else in your output, then define a template. The following
converts <b> elements to <strong>.

<xsl:template match="b|B">
  <strong><xsl:apply-templates select="*|text()" /><strong>
</xsl:template>

Hope this helps. If it doesn't, then send a little more
information about the problem, with a short input document,
stylesheet, and the desired output.

-- 
Warren Hedley


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread