Return-Path:
The previous example showed how you can call a pipeline from another=
block.
But here is even more you can do! A sitemap can also provide pipeline f=
ragements
--- that can be used by other blocks.
--- Add this pipeline to myblock2. It provides a transformation se=
rvice
--- that consists of two XSLT transformation steps:
TBD+++
<?xml version=3D"1.0" encoding=3D"UTF-8"?> +++ <map:sitemap xmlns:map=3D"http://apache.org/cocoon/sitemap/1.0"> +++ <map:pipelines> +++ <map:pipeline> +++ <map:match pattern=3D"callingTransformationService"> +++ <map:generate src=3D"demo/welcome.xml"/> +++ <map:transform type=3D"servletService"> +++ <map:parameter name=3D"service"=20 +++ value=3D"servlet:myBlock2:/myXsltTransformation-service"/>= ; +++ </map:transform> +++ <map:serialize type=3D"xml"/> +++ </map:match> +++ </map:pipeline> +++ </map:pipelines> +++ </map:sitemap>=20 ---
Now it can be used from myBlock1
+++When the requests arrives at callingTransformationService p= ipeline, +++ the generator produces SAX events of demo/welcome.xml. There i= s nothing +++ special here. The interesting part comes with the following transformer= of type +++ servletService. It calls a transformation service which is pro= vided by +++ myBlock2.
=20 ---TBD+++
Add this service to the sitemap of myBlock2 +++ (getting-started-app/myBlock2/src/main/resources/COB-INF/sitemap.xm= ap). +++ It consists of one XSLT transformation step:
=20 ---...
+++<?xml version=3D"1.0" encoding=3D"UTF-8"?> +++ <map:sitemap xmlns:map=3D"http://apache.org/cocoon/sitemap/1.0"> +++ <map:pipelines> +++ <map:pipeline> +++ <map:match pattern=3D"myXsltTransformation-service"> +++ <map:generate src=3D"service-consumer:"/>= ; +++ <map:transform src=3D"myXsltTransformation.xslt"/> +++ <map:serialize type=3D"xml"/> +++ </map:match> +++ </map:pipeline> +++ </map:pipelines> +++ </map:sitemap>=20 +++
The generator uses the service-consumer protocol which initializes t= he +++ service. Then the pipeline continues with an XSLT transformation +++ myXsltTranformation.xslt, which has to be put into the same di= rectory +++ as the myBlock2 sitemap:
+++=20 +++<?xml version=3D"1.0" encoding=3D"UTF-8"?> +++ <xsl:stylesheet version=3D"1.0" xmlns:xsl=3D"http://www.w3.org/1999/= XSL/Transform"> +++ =C2=A0 <xsl:template match=3D"/"> +++ =C2=A0=C2=A0=C2=A0 <html> +++ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <head> +++ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <title>Output of the X= SLT transformation service.</title> +++ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </head> +++ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <body> +++ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Output of the XSLT transform= ation service. +++ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </body> +++ =C2=A0=C2=A0=C2=A0 </html> +++ =C2=A0 </xsl:template> +++ </xsl:stylesheet> ++++++=20 +++
Point your browser at +++ http://localhost:8888/myBlock1/callingTransformationService an= d see the +++ output of the pipeline.
+++=20 +++Beside transformation services there are also generat= ion and a +++ serialization services.
+++=20