xsl-list
[Top] [All Lists]

RE: Tags to HTML page

2004-08-11 02:28:34
Sorry for the basic question, but i don't understand the use of
<xsl:apply-templates/> in Michael solution. If it was <xsl:value-of
select="."/> i can understand what it does, but not like that...

I don't know what can appear inside an <h3> element. I don't know if you
told me, but even if you did, I prefer to write the code in such a way that
it doesn't matter. By writing xsl:apply-templates, I am saying "process
whatever you find inside the h3 element according to the rules defined for
that kind of content". For example, if there is an <a> element inside the
<h3>, then it will process that according to the rules for handling <a>
elements. If all it finds is text, then the text will be processed using the
default rule for text nodes, which is equivalent to <xsl:value-of
select="."/>.

By contrast, if you use xsl:value-of directly, your template rule will only
handle an <h3> element properly if it contains pure text.

This use of apply-templates is central to the "rule-based" approach to
stylesheet design, which enables you to make your stylesheet resilient to
variations in document structure, and thus to increase the reusability of
the template rules.

You described your problem in rule-based terms "when there is an h3 element,
do this...", and that's precisely the structure a rule-based stylesheet
should take.

Michael Kay  



For my understanding, the apply-templates will call the 
template in wich it is
inserted, in this case <xsl:template match="h3">? But then 
there is a loop
processing, or am i thinking procedural?

I normally use w3schools site as reference, but the example 
there is not clear
to me, either...

Again, sorry for the basic question...

Citando Michael Kay <mhk(_at_)mhk(_dot_)me(_dot_)uk>:


Whenever there is a  <h3> tag I should surrond it with more tags

<myowntag:bind path="someCode">
<h3>Test Conversion</h3>
</myowntag>


Basically the input is a JSP and I need to add some Tag
libraries to it.

What would be the best way to do it.


<xsl:template match="h3">
<myowntag:bind path="someCode">
<h3><xsl:apply-templates/></h3>
</myowntag:bind>
</xsl:template>

Note that writing a stylesheet in terms of template rules 
corresponds
exactly to the way you described the problem: "whenever 
there is an <h3> tag
[you mean element] I should..."

Michael Kay



--+------------------------------------------------------------------
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>
--+--









O SAPO já está livre de vírus com a Panda Software, fique você também!
Clique em: http://antivirus.sapo.pt

--+------------------------------------------------------------------
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>