Re: Issues using parameters with namespaces
George Joseph via xslt <[email protected]> Tue, 1 Mar 2022 05:44:12 -0700
| Newsgroups | gmane.comp.gnome.lib.xslt |
|---|---|
| Message-ID | <CAP=uFEvPrd9QXV_MdzOfi69tco6+oyfdsg7kN-c6s7OFT_1w+g@mail.gmail.com> |
--===============5598828773081218148== Content-Type: multipart/alternative; boundary="00000000000092ff3205d927861c" --00000000000092ff3205d927861c Content-Type: text/plain; charset="UTF-8" On Tue, Mar 1, 2022 at 3:37 AM Nick Wellnhofer <[email protected]> wrote: > On 28/02/2022 22:07, George Joseph wrote: > > Actually "//*[name()='dm:device']" works as well so maybe that's what > I'll do. > > This seems like the best work-around. > Yeah makes sense. I'll need to do some performance testing regardless of which way I go since I'm parsing SIP messages in real time. > > Is there any reason why path parameters with namespaces haven't been > > supported? > > Would a pull request to add the namespaces > in xsltNewTransformContext be > > considered? > > How parameters are passed isn't covered by the standard, so it's up to the > implementation to come up with something. It seems natural to allow XPath > expressions, but it's not clear how to handle namespaces. Simply taking > the > namespace defitinions from the root element of the root stylesheet should > do > what most people expect, but it is somewhat fragile. > > True. > 1. Passing parameters from the command line > > Supporting namespaces in a clean way would probably require a separate > channel > to register namespaces just for parameter evaluation. Even Saxon doesn't > seem > to support custom namespaces in parameter expressions: > > "The static context for this XPath expression includes only the standard > namespaces conventionally bound to the prefixes xs, fn, xsi, and saxon." > [1] > > 2. Passing parameters using the API > > The most flexible approach is probably an API to set parameters directly, > similar to Saxon's XsltTransformer [2]. This would even allow to pass > nodes > from external documents as parameters. But if you want to combine that > with > XPath expressions, you'd have to evaluate them yourself. > > Nick > > Gotcha. Thanks for all your help Nick! > > [1] > https://www.saxonica.com/documentation11/index.html#!using-xsl/commandline > [2] > > https://www.saxonica.com/documentation11/index.html#!javadoc/net.sf.saxon.s9api/XsltTransformer@setParameter > --00000000000092ff3205d927861c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">= <div dir=3D"ltr" class=3D"gmail_attr">On Tue, Mar 1, 2022 at 3:37 AM Nick W= ellnhofer <<a href=3D"mailto:[email protected]">[email protected]</a= >> wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px= 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On = 28/02/2022 22:07, George Joseph wrote:<br> > Actually=C2=A0"//*[name()=3D'dm:device']" works as w= ell so maybe that's what I'll do.<br> <br> This seems like the best work-around.<br></blockquote><div><br></div><div>Y= eah makes sense.=C2=A0 =C2=A0I'll need to do some performance testing r= egardless</div><div>of which way I go since I'm parsing SIP messages in= real time.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style= =3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding= -left:1ex"> >=C2=A0 =C2=A0 =C2=A0Is there any reason why path parameters with namesp= aces haven't been<br> >=C2=A0 =C2=A0 =C2=A0supported?<br> >=C2=A0 =C2=A0 =C2=A0Would a pull request to add the namespaces in=C2=A0= xsltNewTransformContext=C2=A0be<br> >=C2=A0 =C2=A0 =C2=A0considered?<br> <br> How parameters are passed isn't covered by the standard, so it's up= to the <br> implementation to come up with something. It seems natural to allow XPath <= br> expressions, but it's not clear how to handle namespaces. Simply taking= the <br> namespace defitinions from the root element of the root stylesheet should d= o <br> what most people expect, but it is somewhat fragile.<br> <br></blockquote><div><br></div><div>True.</div><div>=C2=A0</div><blockquot= e class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px s= olid rgb(204,204,204);padding-left:1ex"> 1. Passing parameters from the command line<br> <br> Supporting namespaces in a clean way would probably require a separate chan= nel <br> to register namespaces just for parameter evaluation. Even Saxon doesn'= t seem <br> to support custom namespaces in parameter expressions:<br> <br> "The static context for this XPath expression includes only the standa= rd <br> namespaces conventionally bound to the prefixes xs, fn, xsi, and saxon.&quo= t; [1]<br> <br> 2. Passing parameters using the API<br> <br> The most flexible approach is probably an API to set parameters directly, <= br> similar to Saxon's XsltTransformer [2]. This would even allow to pass n= odes <br> from external documents as parameters. But if you want to combine that with= <br> XPath expressions, you'd have to evaluate them yourself.<br> <br> Nick<br> <br></blockquote><div><br></div><div>Gotcha.=C2=A0 Thanks for all your help= Nick!</div><div><br></div><div>=C2=A0</div><blockquote class=3D"gmail_quot= e" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204)= ;padding-left:1ex"> <br> [1] <a href=3D"https://www.saxonica.com/documentation11/index.html#!using-x= sl/commandline" rel=3D"noreferrer" target=3D"_blank">https://www.saxonica.c= om/documentation11/index.html#!using-xsl/commandline</a><br> [2] <br> <a href=3D"https://www.saxonica.com/documentation11/index.html#!javadoc/net= .sf.saxon.s9api/XsltTransformer@setParameter" rel=3D"noreferrer" target=3D"= _blank">https://www.saxonica.com/documentation11/index.html#!javadoc/net.sf= .saxon.s9api/XsltTransformer@setParameter</a><br> </blockquote></div></div> --00000000000092ff3205d927861c-- --===============5598828773081218148== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ xslt mailing list, project page http://xmlsoft.org/XSLT/ [email protected] https://mail.gnome.org/mailman/listinfo/xslt --===============5598828773081218148==--