You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Edierley Messias <ed...@dcc.ufmg.br> on 2001/01/11 02:24:28 UTC
Following text
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Hi people,
Thanks for you, I resolved the problem to select the text nodes before the
<br/> elements that have the string-length < 150.
Using the template:
<xsl:template
match="br[preceding-sibling::node()[1]/self::text()[string-length(.) < 150]]"/>
But now I have a problem, the text can be like this DOM tree:
<root>
_______|_______
| | | |
text1 <b> text3 <br/>
|
text2
Now I have to sum the string-length from text1, text2, text3 and test
if the sum is less than 150.
I tried with any kind of methods, but I cannot taked the values to sum,
using
xpath-axes.
Does anyone have any ideas?
Some help will be apreciated.
Thanks in advance.
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
_________________________
Edierley Messias
www.dcc.ufmg.br/~edierley
icq 32943484
Re: problem with preceding-sibling and following-sibling
Posted by James Melton <ja...@cylogix.com>.
James Melton wrote:
>
> 1. "preceding-sibling::fld/@row" will return a node-set of "row"
> attributes.
As I think about this statement it seems nonsensical. An attribute is
not a node so you cannot have a node-set of attributes.
Try: "preceding-sibling::fld[1]/@row" (again untested) to see if that is
what you want.
Sorry for the messy first explanation.
Jim
____________________________________________________________
James Melton CyLogix
609.750.5190 609.750.5100
james.melton@cylogix.com www.cylogix.com
RE: problem with preceding-sibling and following-sibling
Posted by Kurt Heston <ku...@yahoo.com>.
Essentially what I'm trying to do is make decisions about how to process the
current node in a for-each loop based on values that both the node that was
just processed and the node that will be processed next have. Since I can't
update a variable with the values I need to check, I'd like to be able to
determine things based on a node's position in the tree. This is how I got
into the whole preceding/following-sibling mess. Would the "position"
function get me where I want to go? Since the preceding-sibling code has
not been tested, how do I get where I need to go?
-----Original Message-----
From: Kurt Heston [mailto:kurtheston@yahoo.com]
Sent: Thursday, April 19, 2001 12:47 PM
To: xalan-dev@xml.apache.org
Subject: RE: problem with preceding-sibling and following-sibling
This "preceding-sibling::fld/@row" and "preceding-sibling::fld/@row[1]"
return the same thing. It looks like the "reverse document order" part may
not be working. Is there a work around?
-----Original Message-----
From: James Melton [mailto:james.melton@cylogix.com]
Sent: Thursday, April 19, 2001 12:15 PM
To: xalan-dev@xml.apache.org
Subject: Re: problem with preceding-sibling and following-sibling
I do not think you are seeing a bug.
I think what will happen with this code is:
1. "preceding-sibling::fld/@row" will return a node-set of "row"
attributes.
2. This nodeset will be compared to the string resulting from the
current node's "row" attribute. That comparison using "<" compares
each node of the node-set with the string.
3. The first (in document order) "row" attribute apparently is included
in this node-set, so it will be compared to the string from the current
"row" attribute (ignoring any short-circuit optimization that may be
done).
I think you want to look only at the immediately preceding sibling.
Perhaps something like: "preceding-sibling::fld/@row[1]" (note that this
is untested code). Of course following-sibling works similarly.
Jim.
Kurt Heston wrote:
>
> When the number of the row
> attribute changes, I need to start a new row. My code looks something
like:
>
> <xsl:if test="preceding-sibling::fld/@row < @row">
> <!-- new row -->
> </xsl:if>
>
____________________________________________________________
James Melton CyLogix
609.750.5190 609.750.5100
james.melton@cylogix.com www.cylogix.com
RE: problem with preceding-sibling and following-sibling
Posted by Kurt Heston <ku...@yahoo.com>.
This "preceding-sibling::fld/@row" and "preceding-sibling::fld/@row[1]"
return the same thing. It looks like the "reverse document order" part may
not be working. Is there a work around?
-----Original Message-----
From: James Melton [mailto:james.melton@cylogix.com]
Sent: Thursday, April 19, 2001 12:15 PM
To: xalan-dev@xml.apache.org
Subject: Re: problem with preceding-sibling and following-sibling
I do not think you are seeing a bug.
I think what will happen with this code is:
1. "preceding-sibling::fld/@row" will return a node-set of "row"
attributes.
2. This nodeset will be compared to the string resulting from the
current node's "row" attribute. That comparison using "<" compares
each node of the node-set with the string.
3. The first (in document order) "row" attribute apparently is included
in this node-set, so it will be compared to the string from the current
"row" attribute (ignoring any short-circuit optimization that may be
done).
I think you want to look only at the immediately preceding sibling.
Perhaps something like: "preceding-sibling::fld/@row[1]" (note that this
is untested code). Of course following-sibling works similarly.
Jim.
Kurt Heston wrote:
>
> When the number of the row
> attribute changes, I need to start a new row. My code looks something
like:
>
> <xsl:if test="preceding-sibling::fld/@row < @row">
> <!-- new row -->
> </xsl:if>
>
____________________________________________________________
James Melton CyLogix
609.750.5190 609.750.5100
james.melton@cylogix.com www.cylogix.com
Re: problem with preceding-sibling and following-sibling
Posted by James Melton <ja...@cylogix.com>.
I do not think you are seeing a bug.
I think what will happen with this code is:
1. "preceding-sibling::fld/@row" will return a node-set of "row"
attributes.
2. This nodeset will be compared to the string resulting from the
current node's "row" attribute. That comparison using "<" compares
each node of the node-set with the string.
3. The first (in document order) "row" attribute apparently is included
in this node-set, so it will be compared to the string from the current
"row" attribute (ignoring any short-circuit optimization that may be
done).
I think you want to look only at the immediately preceding sibling.
Perhaps something like: "preceding-sibling::fld/@row[1]" (note that this
is untested code). Of course following-sibling works similarly.
Jim.
Kurt Heston wrote:
>
> When the number of the row
> attribute changes, I need to start a new row. My code looks something like:
>
> <xsl:if test="preceding-sibling::fld/@row < @row">
> <!-- new row -->
> </xsl:if>
>
____________________________________________________________
James Melton CyLogix
609.750.5190 609.750.5100
james.melton@cylogix.com www.cylogix.com
problem with preceding-sibling and following-sibling
Posted by Kurt Heston <ku...@yahoo.com>.
I'm trying to produce an HTML table and am running into some difficulty. My
XML document has nodes with a "row" attribute. When the number of the row
attribute changes, I need to start a new row. My code looks something like:
<xsl:if test="preceding-sibling::fld/@row < @row">
<!-- new row -->
</xsl:if>
The problem is that preceding-sibling seems to always want to return the
sibling that is first in the tree level, not the one that directly precedes
the current node on the same level, no matter if there are 2 nodes or 400.
The behavior of following-sibling is similar, returning only the last node
in the level.
Is this a bug? I'm currently using Xalan-1.2.2, if I upgraded to Xalan-2
would this problem be fixed?
Re: Following text
Posted by Gary L Peskin <ga...@firstech.com>.
Edierley Messias wrote:
>
> =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
> Hi people,
> Thanks for you, I resolved the problem to select the text nodes before the
> <br/> elements that have the string-length < 150.
> Using the template:
>
> <xsl:template
> match="br[preceding-sibling::node()[1]/self::text()[string-length(.) < 150]]"/>
>
> But now I have a problem, the text can be like this DOM tree:
> <root>
> _______|_______
> | | | |
> text1 <b> text3 <br/>
> |
> text2
>
> Now I have to sum the string-length from text1, text2, text3 and test
> if the sum is less than 150.
>
> I tried with any kind of methods, but I cannot taked the values to sum,
> using
> xpath-axes.
>
> Does anyone have any ideas?
> Some help will be apreciated.
I'm not exactly sure what you want to do. However, if you define a
variable and create a result tree fragment like this:
<xsl:variable name="foo">
<xsl:copy-of select="select-expr">
</xsl:variable>
then, you can invoke string($foo) which will create a string which is
the concatenation of the string-values of all text nodes in the RTF.
You could then apply string-length to that like this:
string-length(string($foo))
Gary