xsl-list
[Top] [All Lists]

Re: Entity Questions

2005-01-17 15:56:28
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">
<fo:block>
  <xsl:apply-templates/>
 </fo:block>
</xsl:template>

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[(_at_)NAME=$textname] !=''" >
<xsl:value-of select="DATA/VERSION/ITEM[(_at_)NAME=$textname]"/>
</xsl:if>
</xsl:template>

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

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?

Thanks,

Luke



----- Original Message ----- 
From: "Michael Kay" <mike(_at_)saxonica(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
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
processing
model, and it's as well to get the right model into your head. When you
see
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
three.
The start and end tags are produced only when the result tree is
serialized;
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
modify
it, replace the rules that generate HTML with rules that generate FO.

Michael Kay
http://www.saxonica.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>
--~--



<Prev in Thread] Current Thread [Next in Thread>