RE: Adding a stylesheet PI

> Suppose you have a nice pipeline which constructs some nice XML
> document, and you want to add a (static) stylesheet PI to it.
> 
> I have not found any clean way to do this -- I've ended up doing this:
> 
>  <p:insert match="/foo" position="last-child">
>   <p:input port="insertion">
>    <p:pipe step="[previous]" port="result"/>
>   </p:input>
>   <p:input port="source">
>    <p:inline>
>     <foo><?xml-stylesheet type="text/xsl" href="oToHtml.xsl"?></foo>
>    </p:inline>
>   </p:input>
>  </p:insert>
> 
>  <p:unwrap match="/foo"/>
> 
> Can anyone improve on that?

I think this is about as far as you can get with the 'plain XProc' approach. You can also imagine inserting a "<?xml-stylesheet?>foo" document into the original document and the using p:delete to remove the "foo" element, but that is just a variation on the same theme. The problem is that the content of p:inline must be a well-formed XML document, so you cannot specify a processing instruction without some kind of a dummy document element next.

What about using p:xslt (p:xquery?) to add the PI?

Vojtech



--
Vojtech Toman
Consultant Software Engineer
EMC | Information Intelligence Group
vojtech.toman@emc.com
http://developer.emc.com/xmltech

Received on Tuesday, 15 March 2011 10:21:47 UTC