[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Entity Questions

Subject: Re: [xsl] Entity Questions
From: "Luke Shannon" <lshannon@xxxxxxxxxxxxxxx>
Date: Mon, 17 Jan 2005 17:56:28 -0500

Thanks Michael, I have a lot to learn in this area. Also the sytem I am
working with was not written by someone who knew alot about XSL either.

So taking this template for example:

<!-- the html i am looking at is machine generated and in all caps -->
<xsl:template match="P">

This is matching a P node (<P>) and replacing it with the <fo:block>the
contents of the matched node</fo:block>.

Is this correct?

If this is correct than I should be able to do the following:

<!-- output the text from the xml document -->
<xsl:template name="text_display_and_edit">
<xsl:param name="text_number" />
<xsl:param name="textname" select="concat('TEXT',$text_number)" />
<xsl:if test="DATA/VERSION/ITEM[@NAME=$textname] !=''" >
<xsl:value-of select="DATA/VERSION/ITEM[@NAME=$textname]"/>

<!-- this template will catch the <P> and output their contents inside of
<fo:block> instead-->
<xsl:template match="P">

Is this making more sense?

One thing I don't understand. How does <xsl:apply-template/> manage to write
the content of the node out?



----- Original Message ----- 
From: "Michael Kay" <mike@xxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Monday, January 17, 2005 5:14 PM
Subject: RE: [xsl] Entity Questions

> > The template this starts in begins like this:
> >
> > <xsl:template match="*" mode="_KCXFILE_">
> >
> > NOTE:
> > _KCXFILE_ contains the XML document.
> No, a mode doesn't contain anything. It's a label for a template rule that
> must match the mode specified when apply-templates is called: this allows
> you to invoke different rules to process the same nodes under different
> conditions.
>  This is an existing
> > system, I didn't
> > write it so am not clear on why certain things were done the
> > way they were.
> >
> >  This template outputs all the FO tags to start the FO
> > document.
> It's sometimes natural to think of the transformation outputting the start
> tag, then the content, then the end tag. But that's not the XSLT
> model, and it's as well to get the right model into your head. When you
> this in the stylesheet
> <b><xsl:apply-templates/></b>
> you are seeing two element nodes: a b element and an xsl:apply-templates
> element. The b element is evaluated to produce a b element in the result
> tree. The xsl:apply-templates element is evaluated to produce the children
> of the b element in the result tree. There are two actions here, not
> The start and end tags are produced only when the result tree is
> writing an element to the result tree is an atomic operation.
> You can easily spot the people who haven't understood this: they sprinkle
> their stylesheets liberally with "disable-output-escaping".
> >
> > While the content is being outputed there are sometimes HTML
> > tags. I want
> > the system to switch those out for FO tags.
> So you want to substitute template rules that output FO elements for the
> existing template rules that output HTML elements.
> >
> > It is within this template I would like to examine each
> > output before it is
> > actually outputed for tags I would like to replace.
> No, that's not the way to tackle it. Don't generate the HTML and then
> it, replace the rules that generate HTML with rules that generate FO.
> Michael Kay
> http://www.saxonica.com/

Current Thread