[XSL-LIST Mailing List Archive Home]
[Reply To This Message]
Re: testing element's contents
Subject: Re: testing element's contents|
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Thu, 03 Oct 2002 19:07:40 +0200
you seem again to be wrong here. Tha value of a node is the concatenated
string of every descendant text node. So
will not match on <p><strong>this is bold text</strong></p>.
Nathan Shaw wrote:
Thanks Wendell. Thinking it over, your simple template
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
will not work, as much as I wish it would, as I am
allowing other elements such as <strong> and <em> and
I could get passed a node set like this
<p><strong>this is bold text</strong></p>
<p><em>this is bold text</em></p>
For both of those cases, they would need to get
wrapped in a p tag in the output.
So, I do need to specifically look to see if the p
element's child nodes are made up of either
1) only a Media element
2) only a Media element wrapped by a Link element
If either of those cases is true, I do not want to
wrap the output in a p tag. Otherwise, I do.
I hope that makes it a bit clearer.
--- Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> wrote:
At 11:08 AM 10/3/2002, you wrote:
Thanks to everyone who gave me advice on my
post about images and captions. Now, I have another
tricky lil' xslt problem. If a paragraph element
contains ONLY a media element OR a media element
surrounded by a link element and nothing more
no other nodes, be they text or not), such as:
I need to strip the p tags out of resulting output.
Okay. Quibbles: translated into XSL-speak, what you
want to do is process
the children of p, but not create any node for the p
itself. (XSLT doesn't
know from 'tags', it knows about nodes, meaning
things like elements and
attributes.) Also: you seem to be giving us
something different from
However, if it does contain other nodes, such as:
height="255" width="432"/>This is my news release.
authors will be typing the news release content in
here! I am not sure what this news release is even
about, but lets see how it comes out in XML, shall
As I see it coming out as:</p>
I need to leave it alone.
Could your problem be restated fairly as "if there's
any text content in
the paragraph, I need a paragraph in my output to
wrap it, otherwise not"?
If so, you could do:
<!-- this tests true if the paragraph has any
at all after whitespace normalization.
This only occurs
if the paragraph or any of its
descendants has non-whitespace
text content -->
This could also be expressed as two simpler
Here, the first template serves as a default, and
the second one fires
whenever it matches but not otherwise (it has a
higher priority since its
match is more complex).
If your logic is more complex than what I'm
inferring (e.g. if it is
actually more dependent on the actual type of nodes
you have down there,
Media or whatever) you need to do something closer
to what you already
have. Refine the logic of your requirement and you
can refine the code....
Here is what I have so far. It only looks to see if
media element or a media element wrapped by a link
element exists, but does not consider if there is a
text node after a media or link element.
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format