- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Mon, 12 Mar 2007 09:52:46 +0000
- To: public-xml-processing-model-wg@w3.org
Norm, Norman Walsh wrote: > / Jeni Tennison <jeni@jenitennison.com> was heard to say: > |> So what would a use of p:xslt look like given this declaration? > | > | <p:xslt> > | <p:input port="source"> > | <p:pipe step="otherstep" port="result" /> > | </p:input> > | <p:input port="stylesheet"> > | <p:document href="stylesheet.xml" /> > | </p:input> > | <p:parameter-set name="parameters"> > | <p:parameter name="skin">classic</p:parameter> > | <p:parameter name="view">normal</p:parameter> > | </p:parameter-set> > | </p:xslt> > > Bleh. The extra level of wrapper seems a bit unfortunate. > There may be something in the parameter sets, but... Not like you to object to verbosity in XML ;) (In fact, I prefer the syntax where the name of the element is the name of the parameter set, which in the above effectively removes the wrapper element, but if that's not used for options it shouldn't be used for parameters.) The status quo is that parameter sets can be defined, but only through namespaces. Say you have a pipeline that involves two transformations, and the stylesheet for the second one is provided as an option to the pipeline: <p:pipeline name="splitAndTransform"> <p:input port="source" /> <p:output port="result" /> <p:option name="transformStylesheet" /> <p:load name="loadStylesheet"> <p:option name="href" select="$transformStylesheet" /> </p:load> <p:xslt name="split"> <p:input port="source"> <p:pipe source="source" step="splitAndTransform" /> </p:input> <p:input port="stylesheet"> <p:document href="split.xsl" /> </p:input> </p:xslt> <p:for-each name="transform" select="/chunks/chunk"> <p:xslt> <p:input port="stylesheet"> <p:pipe step="loadStylesheet" /> </p:input> </p:xslt> </p:for-each> </p:pipeline> Now say that both the split.xsl stylesheet and the main transform stylesheet (whose URI is passed into the pipeline) need to be passed parameters. To create pipelines like this, you have to have one of the following unlikely guarantees: * that the stylesheets use different (local) names for their parameters: then you can declare parameters for the pipeline and import them all into both of the <p:xslt> steps: <p:pipeline name="splitAndTransform"> <p:input port="source" /> <p:output port="result" /> <p:option name="transformStylesheet" /> <p:declare-parameter name="*" /> <p:load name="loadStylesheet"> <p:option name="href" select="$transformStylesheet" /> </p:load> <p:xslt name="split"> <p:input port="source"> <p:pipe source="source" step="splitAndTransform" /> </p:input> <p:input port="stylesheet"> <p:document href="split.xsl" /> </p:input> <p:import-parameter name="*" /> </p:xslt> <p:for-each name="transform" select="/chunks/chunk"> <p:xslt> <p:input port="stylesheet"> <p:pipe step="loadStylesheet" /> </p:input> <p:import-parameter name="*" /> </p:xslt> </p:for-each> </p:pipeline> * that the stylesheets use different namespace URIs for their parameters: then you can declare parameters for the pipeline and import ones with specific namespaces into the <p:xslt> steps: <p:pipeline name="splitAndTransform" xmlns:s="http://www.example.com/ns/split"> <p:input port="source" /> <p:output port="result" /> <p:option name="transformStylesheet" /> <p:declare-parameter name="*" /> <p:load name="loadStylesheet"> <p:option name="href" select="$transformStylesheet" /> </p:load> <p:xslt name="split"> <p:input port="source"> <p:pipe source="source" step="splitAndTransform" /> </p:input> <p:input port="stylesheet"> <p:document href="split.xsl" /> </p:input> <p:import-parameter name="s:*" /> </p:xslt> <p:for-each name="transform" select="/chunks/chunk"> <p:xslt> <p:input port="stylesheet"> <p:pipe step="loadStylesheet" /> </p:input> <p:import-parameter name="*" /> </p:xslt> </p:for-each> </p:pipeline> * that you know the names of all the parameters the stylesheets use: then you can declare specific parameters for the pipeline and pass them (perhaps with different names) into the individual steps: <p:pipeline name="splitAndTransform"> <p:input port="source" /> <p:output port="result" /> <p:option name="transformStylesheet" /> <p:declare-parameter name="splitConfig" /> <p:declare-parameter name="transformConfig" /> <p:load name="loadStylesheet"> <p:option name="href" select="$transformStylesheet" /> </p:load> <p:xslt name="split"> <p:input port="source"> <p:pipe source="source" step="splitAndTransform" /> </p:input> <p:input port="stylesheet"> <p:document href="split.xsl" /> </p:input> <p:parameter name="config" select="$splitConfig" /> </p:xslt> <p:for-each name="transform" select="/chunks/chunk"> <p:xslt> <p:input port="stylesheet"> <p:pipe step="loadStylesheet" /> </p:input> <p:parameter name="config" select="$transformConfig" /> </p:xslt> </p:for-each> </p:pipeline> I think that pipelines should work with arbitrary, unaltered, stylesheets and that the current XProc design places too many constraints on the design of stylesheets used in pipelines. With parameter sets, you would write (something like): <p:pipeline name="splitAndTransform"> <p:input port="source" /> <p:output port="result" /> <p:option name="transformStylesheet" /> <p:declare-parameter-set name="splitParameters" /> <p:declare-parameter-set name="transformParameters" /> <p:load name="loadStylesheet"> <p:option name="href" select="$transformStylesheet" /> </p:load> <p:xslt name="split"> <p:input port="source"> <p:pipe source="source" step="splitAndTransform" /> </p:input> <p:input port="stylesheet"> <p:document href="split.xsl" /> </p:input> <p:parameter-set name="parameters" select="$splitParameters" /> </p:xslt> <p:for-each name="transform" select="/chunks/chunk"> <p:xslt> <p:input port="stylesheet"> <p:pipe step="loadStylesheet" /> </p:input> <p:parameter-set name="parameters" select="$transformParameters" /> </p:xslt> </p:for-each> </p:pipeline> Cheers, Jeni
Received on Monday, 12 March 2007 09:53:05 UTC