Geert Josten wrote:
Hi David,
Actually, it has. Sandor suggested to generate an XSL using the xpaths
you want to match as input. As long as not every requests needs a new
XSL, this will be fairly efficient. And though a DOM tree is being build
from the input SAX events for the XSL transform, you do not need to
bother about it and neither about converting it to SAX again.
It could be more efficient to write a XPath testing Transformer, but
doing it without DOM will require you to put a lot of information into
memory, parse the xpath expressions and match each event against the
expressions. I have seen attempts in other languages and I cannot
recommend this procedure, not for full Xpath support ;-P..
In short, I think generating an XSL is by far the easiest way and gives
you full power at the same time. Let know if you need help on this...
Cheers,
Geert
Oh I see. Even though the xpaths will not change much I do not believe
XSL will work. For example I have two xpaths that both should match the
same thing. Eg
-----------------
<template match="//xhtml:img">
<copy>
<attribute name="class" select="concat('match1 ', @class)"/>
</copy>
</template>
<template match="//xhtml:[EMAIL PROTECTED]'more-exact']">
<copy>
<attribute name="class" select="concat('match2 ', @class)"/>
</copy>
</template>
----------------
Now if I had xhtml like this:'
----------------
<img/>
<img id="more-exact'/>
--------------
the results obviously will be
---------------
<img class="match1"/>
<img id="more-exact" class="match2"/>
--------------
i WANT the results to be
---------------
<img class="match1"/>
<img id="more-exact" class="match1 match2"/>
--------------
sooo.. pretty much I want BOTH xpaths to match; not just the highest
prioritized one.
Calling the first template from the 2nd one is not an option. This
example is simplified. In the actual problem there will be many more
xpaths and we would need to dynamically create the xsl files... and if
one template needs to call another one I have no idea how I would figure
that out. (Some how I would have to know that a group of xpaths all
match something so the templates need to call each other.)
This is why I am not using an xsl file. Anyone know of a good way to do
this in xsl? (I came up with one or two ways of doing it but it in no
way an elegant solution -- and probably extremely slow.) MAYBE if
xsl:next-match was supported I could do this -- but xalan does not seem
to have support for it yet.
So who has a brilliant way of doing this? :-)
David
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]