xsl-list
[Top] [All Lists]

RE: [xsl] Embedded bold,italic,anchors etc.

2008-06-11 08:49:32
Yes, you're doing a lot of this kind of thing:

             <xsl:for-each select="p">
                <p><xsl:value-of select="." /></p>
             </xsl:for-each>

when you should be doing

<xsl:apply-templates select="p"/> 

Value-of essentially causes the markup from this point down in the tree to
be ignored.

In fact, generally, you're making far too much use of for-each and value-of
than is healthy in a document-oriented transform. Try to use rule-based
recursive descent processing (often called "push processing") all the way
down. The coding style should be, except where something else is needed,
that each element matches a template rule, which does something specific to
that element and then does apply-templates to its children.

Michael Kay
http://www.saxonica.com/

-----Original Message-----
From: Craig Riley [mailto:craig(_at_)thelifeofriley(_dot_)org] 
Sent: 11 June 2008 16:10
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Embedded bold,italic,anchors etc.

Wow some great responses (and the usual not so great ones :)

The reason I did not supply any code is because a) This was 
one of the first things I tried to do and because it didn't 
work I deleted the code, b) the code I have now is quite 
large and c) I just wanted a nudge in right direction so I 
wrote an example peice of code out.

 From what I have read I was probably using the value-of 
instead of the recursive technique somebody suggested. For 
what it's worth this is the code I have to date, I'm sure 
there's tons of things wrong with it but that's part of 
learning! I can already see I'm not using templates nowhere 
near enough! :(

Thanks again for the helpful emails

Cheers

Craig



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