You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Rasik Pandey <ra...@ajlsm.com> on 2003/09/25 14:26:06 UTC

SAX ElementFilter Transformer

Hello All,

I have written a simple element filter, an XMLPipe which can strip
elements from a SAX stream based upon a list of parameters (element
names, etc). It has two modes, the first being to strip the elements in
the list from the SAX stream, and the second being to only pass the
elements in the list on to the XMLConsumer.  We are currently using it
as a sitemap Transformer. If there is any interest in this for Cocoon,
please let me know.

Regards,

Rasik Pandey  


RE : RE : SAX ElementFilter Transformer

Posted by Rasik Pandey <ra...@ajlsm.com>.
Hello,

 >I am just curious, why couldn't this be done using an XALT 

You are right it could be easily down in that fashion, but we do it in
SAX for better performance.

Rasik

 >transformer ?
 >
 >
 >At 09:35 AM 9/25/2003, Rasik Pandey wrote:
 >>Salut,
 >>
 >>  >I'm interested :=)
 >>  >
 >>  >I was planning to make one actually.
 >>  >
 >>  >Could you tell me more about it please?
 >>
 >>Vous êtes où en l'hexagone?
 >>
 >>Here is some quick commentary, let me know if it isn't clear!
 >>
 >><!--transformer for filtering elements as sax events
 >>The parameter names are a list of :
 >>a)element names (qualified or unqualified
 >>b)namespace uris of elements unwanted
 >>         (this will also remove the startPrefixMapping and 
 >>endPrefixMapping events for the uri) c)namespace prefixes of 
 >elements 
 >>unwanted (this will also remove the startPrefixMapping and 
 >>endPrefixMapping events for the uri)
 >>d)simple downward traversal xpath not referecing 
 >attributes(but maybe in
 >>the future)
 >>
 >>The values can either be empty strings or the exact namespace uri of 
 >>the element. for which the sax events will be stripped or kept 
 >>depending on the "send" parameter, the "send" parameter default is 
 >>"false" meaning strip the elements specified as parameters.
 >>
 >>Transformer definition in sitemap:
 >>
 >><map:transformer name="elemFilter" 
 >>src="fr.gouv.culture.sdx.sitemap.transformers.ElementFilter"
 >>logger="sitemap.transformer.elemFilt">
 >>
 >>internal parameter indicating whether to send elements in 
 >the parameter 
 >>list or not (this parmeter name (send) should be prefixed 
 >(blah:send) 
 >>in the future to avoid any confusions with element names) :
 >>
 >><parameter name="send" value="true | false"/>
 >>
 >>example params :
 >>
 >><parameter name="http://bnsa.aquitaine.fr/ap/format-pivot/1.0"
 >>value=""/>
 >><parameter 
 >>name="/sdx:document/sdx:results/sdx:result/record/metadata/pa
 >:unite_doc
 >>u
 >>mentaire" value=""/>
 >><parameter name="pa:unite_documentaire"
 >>value="http://bnsa.aquitaine.fr/ap/format-pivot/1.0"/>
 >>
 >></map:transformer>
 >>
 >>Using it in a pipeline:
 >>
 >><map:match ...>
 >>         ...
 >>                 <map:transform type="elemFilter"/>
 >>
 >>                 OR
 >>                 <map:transform type="elemFilter">
 >>                         <map:parameter name="send" value="true | 
 >>false"/>
 >>                         other element name params
 >>                 </map:transform>
 >>         ...
 >></map:match ...>
 >>
 >>
 >>-->
 >>
 >>
 >>Rasik
 >


RE : SAX ElementFilter Transformer

Posted by Oleg Dulin <ol...@opence.net>.
I am just curious, why couldn't this be done using an XALT transformer ?


At 09:35 AM 9/25/2003, Rasik Pandey wrote:
>Salut,
>
>  >I'm interested :=)
>  >
>  >I was planning to make one actually.
>  >
>  >Could you tell me more about it please?
>
>Vous êtes où en l'hexagone?
>
>Here is some quick commentary, let me know if it isn't clear!
>
><!--transformer for filtering elements as sax events
>The parameter names are a list of :
>a)element names (qualified or unqualified
>b)namespace uris of elements unwanted
>         (this will also remove the startPrefixMapping and
>endPrefixMapping events for the uri)
>c)namespace prefixes of elements unwanted
>(this will also remove the startPrefixMapping and endPrefixMapping
>events for the uri)
>d)simple downward traversal xpath not referecing attributes(but maybe in
>the future)
>
>The values can either be empty strings or the exact namespace uri of the
>element. for which the sax events will be stripped or kept depending on
>the "send" parameter, the "send" parameter default is "false" meaning
>strip the elements specified as parameters.
>
>Transformer definition in sitemap:
>
><map:transformer name="elemFilter"
>src="fr.gouv.culture.sdx.sitemap.transformers.ElementFilter"
>logger="sitemap.transformer.elemFilt">
>
>internal parameter indicating whether to send elements in the parameter
>list or not
>(this parmeter name (send) should be prefixed (blah:send) in the future
>to avoid any confusions with element names) :
>
><parameter name="send" value="true | false"/>
>
>example params :
>
><parameter name="http://bnsa.aquitaine.fr/ap/format-pivot/1.0"
>value=""/>
><parameter
>name="/sdx:document/sdx:results/sdx:result/record/metadata/pa:unite_docu
>mentaire" value=""/>
><parameter name="pa:unite_documentaire"
>value="http://bnsa.aquitaine.fr/ap/format-pivot/1.0"/>
>
></map:transformer>
>
>Using it in a pipeline:
>
><map:match ...>
>         ...
>                 <map:transform type="elemFilter"/>
>
>                 OR
>                 <map:transform type="elemFilter">
>                         <map:parameter name="send" value="true |
>false"/>
>                         other element name params
>                 </map:transform>
>         ...
></map:match ...>
>
>
>-->
>
>
>Rasik


RE : SAX ElementFilter Transformer

Posted by Rasik Pandey <ra...@ajlsm.com>.
Salut,

 >I'm interested :=)
 >
 >I was planning to make one actually.
 >
 >Could you tell me more about it please?

Vous êtes où en l'hexagone? 

Here is some quick commentary, let me know if it isn't clear! 

<!--transformer for filtering elements as sax events
The parameter names are a list of :
a)element names (qualified or unqualified
b)namespace uris of elements unwanted
	(this will also remove the startPrefixMapping and
endPrefixMapping events for the uri)
c)namespace prefixes of elements unwanted
(this will also remove the startPrefixMapping and endPrefixMapping
events for the uri)
d)simple downward traversal xpath not referecing attributes(but maybe in
the future)

The values can either be empty strings or the exact namespace uri of the
element. for which the sax events will be stripped or kept depending on
the "send" parameter, the "send" parameter default is "false" meaning
strip the elements specified as parameters.
      
Transformer definition in sitemap:

<map:transformer name="elemFilter"
src="fr.gouv.culture.sdx.sitemap.transformers.ElementFilter"
logger="sitemap.transformer.elemFilt">

internal parameter indicating whether to send elements in the parameter
list or not
(this parmeter name (send) should be prefixed (blah:send) in the future
to avoid any confusions with element names) :

<parameter name="send" value="true | false"/>

example params :

<parameter name="http://bnsa.aquitaine.fr/ap/format-pivot/1.0"
value=""/>
<parameter
name="/sdx:document/sdx:results/sdx:result/record/metadata/pa:unite_docu
mentaire" value=""/>
<parameter name="pa:unite_documentaire"
value="http://bnsa.aquitaine.fr/ap/format-pivot/1.0"/>

</map:transformer>
            
Using it in a pipeline: 
                
<map:match ...>
	...
		<map:transform type="elemFilter"/>

		OR 
		<map:transform type="elemFilter">
			<map:parameter name="send" value="true |
false"/>
			other element name params
		</map:transform>
	...                 
</map:match ...>	
                

-->


Rasik




RE: SAX ElementFilter Transformer

Posted by Nicolas Toper <nt...@jouve.fr>.
Hi, 
I'm interested :=)

I was planning to make one actually.

Could you tell me more about it please?

-----Message d'origine-----
De : Rasik Pandey [mailto:rasik.pandey@ajlsm.com]
Envoye : jeudi 25 septembre 2003 14:26
A : dev@cocoon.apache.org
Objet : SAX ElementFilter Transformer


Hello All,

I have written a simple element filter, an XMLPipe which can strip
elements from a SAX stream based upon a list of parameters (element
names, etc). It has two modes, the first being to strip the elements in
the list from the SAX stream, and the second being to only pass the
elements in the list on to the XMLConsumer.  We are currently using it
as a sitemap Transformer. If there is any interest in this for Cocoon,
please let me know.

Regards,

Rasik Pandey