[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: manipulating text and not losing elements

Subject: Re: manipulating text and not losing elements
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Thu, 13 Oct 2005 09:57:11 -0500
manipulating text documents
> <xml version="1.0">
> <document>
> <sender>someone@xxxxxxxxxxx</sender>
> <indent1>1245 This is some indented text with <italic>Italic</italic>
> and <bold>bold</bold> text</indent1>
> <paragraph>1246 Italic and bold tags are not limited  they can
> <italic>appear</italic> anywhere within the document</paragraph>
> </document>

...

the
> only way to accomplish this is with substring, but using a substring
> requires outputting using <xsl:value-of> which negates all following
> children.

It's probably not the only way, but I think you might have a bad
mental model going on here.  Think of text nodes as always being leaf
children.

ie
> <xml version="1.0">
> <document>
> <sender>someone@xxxxxxxxxxx</sender>
> <indent1>1245 This is some indented text with <italic>Italic</italic>
> and <bold>bold</bold> text</indent1>
> <paragraph>1246 Italic and bold tags are not limited  they can
> <italic>appear</italic> anywhere within the document</paragraph>
> </document>

- = layer in the tree, so nodes mentioned are "contained" by node with
one less -

document
-sender
--text node value=someone@xxxxxxxxxxx
-indent1
--text node value=1245 This is some indented text with
--italic
---text node value=Italic
--text node value= and
--bold
--- text

and so on.

The trick here is that I'm not sure entirely when those number appear.
 If it's regular enough, say always at the start of the first text
node of a paragraph or an indent and is always four lines just do
something like (not tested)

<xsl:value-of (substring(text()[1],4) />
<xsl:apply-templates select="node()[position() > 1]" />

So you process the first text node and then can resume recursing down the
tree.

You might need to get more complicated if you're going to stick to 1.0
and don't know when the numeric sequences can appear.


Jon Gorman






Ultimately I would like the line tagged as <indent1> to
> read the following:
>
> <p classs="indent1">This is some indented text with <em>Italic</em>
> and <strong>bold</strong> text</p>
>
> Ok, hopefully that illustrates my problem well. Thanks in advance for
> any help you guys can offer.
>
> Cheers,
>
> Spencer

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.