Hi all!

 

I’m trying to create an extension function that should return a tree fragment. The problem is that the returned tree fragment doesn’t 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 can’t 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 can’t 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 I’m 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 I’m 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: [EMAIL PROTECTED]
site: www.aptic.se

Reply via email to