Re: [xsl] Embedded bold,italic,anchors etc.
2008-06-11 05:32:12
Methinks you are thinking of XSLT as some sort of procedural language. It
is a declarative language - and you don't need to "program" it do do the
basic built in functionality.
This seems to be a hard thing for my students with a programming background
to realize. They feel a compelling need to "program something".
The XSLT processor will process your entire XML document, creating an
in-memory tree of nodes. It is a hierarchical tree structure that is
isomorphic to the structure of your document. Hence if you have have a
structure <para><bold><italic>text</italic></bold></para>, then in the
resulting tree, the node named para will have a child node named bold, that
has a child node named italic, that has a child text node.
It then traverses that tree of nodes, in document order, and at each node
checks to see if you provided a template matching on that node. If you
didn't - it executes a default template.
If it does find a match, it executes that template. If the template has an
apply-templates in it - it will continue processing all the children of that
node, applying templates as it goes. You merely have to provide a template
for para, bold, italic and anchors - and the processor will trigger the
correct template at the correct place. You don't have to call anything - it
is an automatic part of the XSLT processor.
Cheers...Hugh
CyberSpace Industries 2000 Inc.
Multimedia Promotion
XML Training and Consulting
http://cyberspace-industries-2000.com
----- Original Message -----
From: "Craig Riley" <craig(_at_)thelifeofriley(_dot_)org>
To: "Martin Honnen" <Martin(_dot_)Honnen(_at_)gmx(_dot_)de>
Cc: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Wednesday, June 11, 2008 8:00 AM
Subject: Re: [xsl] Embedded bold,italic,anchors etc.
Hi thanks for the reply, I have tried using the templates but the
problem I had was where to call them from? I don't know how to get the
replace to work within the body of text so to speak.
For example I have:
<p>some text <italic>some italic text</italic></p>
which could happen in numerous paragraphs within the document.
Whenever I "call" the template the peice of italix text is displayed
outside of the paragraph text! I don't know how to convert the italic
tags into <i></i> tags and keep it within the main body of text?
Sorry if this is obvious :(
Cheers
Craig
Quoting Martin Honnen <Martin(_dot_)Honnen(_at_)gmx(_dot_)de>:
Craig Riley wrote:
I have created an XSLT style sheet that does everything I need it to
except for handling embedded text. The XML documents I am transforming
contain the usual italic, bold, superscript, plus hyper links that
need converting into html.
Of course I need them to retain there place in the copy of course.
The key to solve that is usually writing templates for the elements you
want to process where you make sure the necessary transformation
happens and where you use xsl:apply-templates in the body of the
template e.g.
<xsl:template match="foo">
<strong>
<xsl:apply-templates/>
</strong>
</xsl:template>
<xsl:template match="bar">
<em>
<xsl:apply-templates/>
</em>
</xsl:template>
--
Martin Honnen
http://JavaScript.FAQTs.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>
--~--
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
--~------------------------------------------------------------------
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>
--~--
--------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.100 / Virus Database: 270.2.0/1495 - Release Date: 6/10/2008
5:11 PM
--~------------------------------------------------------------------
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>
|
- [xsl] Embedded bold,italic,anchors etc., Craig Riley
- Re: [xsl] Embedded bold,italic,anchors etc., Martin Honnen
- Re: [xsl] Embedded bold,italic,anchors etc., Craig Riley
- Re: [xsl] Embedded bold,italic,anchors etc., Colin Adams
- Re: [xsl] Embedded bold,italic,anchors etc., Martin Honnen
- Re: [xsl] Embedded bold,italic,anchors etc.,
CyberSpace Industries 2000 Inc. <=
- Message not available
- Re: [xsl] Embedded bold,italic,anchors etc., Andrew Welch
- RE: [xsl] Embedded bold,italic,anchors etc., Michael Kay
- Re: [xsl] Embedded bold,italic,anchors etc., Craig Riley
Re: [xsl] Embedded bold,italic,anchors etc., CyberSpace Industries 2000 Inc.
|
Previous by Date: |
Re: [xsl] Embedded bold,italic,anchors etc., CyberSpace Industries 2000 Inc. |
Next by Date: |
[xsl] Re: xsl-list Digest 11 Jun 2008 05:10:01 -0000 Issue 1525, milo |
Previous by Thread: |
Re: [xsl] Embedded bold,italic,anchors etc., Martin Honnen |
Next by Thread: |
Re: [xsl] Embedded bold,italic,anchors etc., Andrew Welch |
Indexes: |
[Date]
[Thread]
[Top]
[All Lists] |
|
|