You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Erik Rydgren <er...@mandarinen.se> on 2004/01/09 09:56:25 UTC
Implementing an extension function that returns result tree fragment
Hi all!
Im trying to create an extension function that should return a tree
fragment. The problem is that the returned tree fragment doesnt
actually reside inside the source document. I must create it on the fly
and return it. To clarify I will show you an example of what I want to
do.
<xsl:variable name=result select=aptic:regexp(//text(),
^the_row.*data (?P<data1>
) more data (?P<data2>
).*)/>
After the call I want the $result variable to contain a traversable tree
fragment that looks something like this
<result>
<row matched=false/>
<row matched=false/>
<row matched=true data1=the fetched data data2=more fetched
data/>
<row matched=false/>
</result>
I have all the extension functionality in place. It gets called while
doing a transformation. The regexp works just fine. The problem is that
I cant create the tree fragment.
First I planned to create the tree fragment inside the source document,
but not actually connecting it to the document. But since the
XalanDocument I get passed to the execute function is read only I cant
create a single extra element in it. I looked at the
XercesDocumentWrapper for an answer but to my knowledge then I would
have to rebuild the wrapper which is probably a bad idea for two
reasons. It is SLOOOW and furthermore deallocating the wrapper nodes
that are already in cached nodelists and so on is just like bringing a
big gun and shooting myself in the foot.
Now Im looking into creating a new document that contains the result
tree. But the problem with that solution is deallocating it afterwards.
Is there somewhere I can register my new document for destruction when
the transformation is finished? Is there a better way? Is what Im
trying to do possible at all?
Thanks in advance
Erik Rydgren
Software engineer
Aptic AB
Kåsatorpsvägen 5
SE 541 34 SKÖVDE
Sweden
tfn: +46(0)500-416506
fax: +46(0)500-413215
mail: <ma...@aptic.se> erik.rydgren@aptic.se
site: <http://www.aptic.se> www.aptic.se
Re: Implementing an extension function that returns result tree fragment
Posted by Joseph Kesselman <ke...@us.ibm.com>.
Use any DOM implementation (EXCEPT the one built into Xalan, which is
deliberately read-only), build your new tree using that, return its root as
the result of your extension function.
______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk