[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSL outputting HTML from an XML source

Subject: Re: XSL outputting HTML from an XML source
From: Warren Hedley <w.hedley@xxxxxxxxxxxxxx>
Date: Mon, 22 May 2000 15:49:14 -0400
xsl outputting
Ariel Garza wrote:
> 
> This is close to what I need but the problem I have where this template
> is called.  In order for this to process a <B> tag, it would need to be
> called in the same node as the <B> tag exists.  I tried to do this:
> 
> <xsl:template match="//B">
>   <B><xsl:value-of select="B"/></B>
> </xsl:template>

When you are inside this template, you are inside the <B> element.
So <... select="B"> will be referring to children of the current <B>
element that are also <B> elements. What you want is <... select=".">.
But, even better, why not apply templates, which will by default copy
text through, but handle italics inside the <B>. You can handle all of
your formatting tags like this :

<xsl:template match="B|I"> <!-- etc -->
  <xsl:copy>  <!-- copies the start tag, without attributes -->
    <xsl:apply-templates /> <!-- processes children -->
  </xsl:copy> <!-- close tag -->
</xsl:template>


> but this doesn't get applied with every template.  The root of my
> problem is that I will not necessarily know where any of these tags will
> happen.  If the person entering content into the XML wants to have an
> underline or italics inline with other content, they would probably put
> <i>blah blah blah</i> in the middle of the XML tag.
> 
> <description>
>   There is a a <i>huge</i> storm coming...
> </description>

I think you just need to use <xsl:apply-templates /> everywhere instead
of <xsl:value-of>. This will ensure that the entire input tree is
processed properly by your templates. If you don't want to deal with
some part of the tree, define an empty template:

<xsl:template match="unwanted_data" />


> Is there a way to have a tag interpreted without prior knowledge as to
> its location in the tree?  An example would be a forced <BR> in a piece
> of content.  I need a block of text + HTML to exist in a single node of
> XML.  If a content manager needs to put in a <B>, or <I> or wants to
> have 2 paragraphs in one block, how would the XSL sheet know that you
> have another paragraph or one of these style tags?  Thanks for the help,
> it is very much appreciated.

You should probably ask your content manager to use <p> tags. In the
absence of that you could translate all carriage returns to <br> tags,
using Steve Muench's br_replace template (if you can't find it in the
archives, I can send you a copy off-list) - but this is probably not
the right solution if they're entering the text in a text editor.

Hope this helps.

-- 
Warren Hedley


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.