Re: namespace prefixes in XSLT parameters

Bruce Miller <[email protected]> Mon, 24 Sep 2012 09:40:03 -0400
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
On 09/23/2012 03:37 PM, Michael Ludwig wrote:
> Bruce R Miller schrieb am 18.09.2012 um 19:10 (-0400):
>
>>    When you pass a parameter to an xslt, for me
>> the common issue was always to quote it enough,
>> since the value is actually an XPath expression:
>>     $stylesheet->transform($document,PARAM=>"'some text'");
>>
>> I thought I'd get fancy and try using the XPath
>> functionality.  I guess it's clear that the XPath
>> will be _evaluated_ inside the stylesheet, and
>> with the document loaded --- otherwise, it wouldn't
>> be much use, right?
>
> I'm surprised. I used to think that wasn't possible. But it is:

Yeah; it's potentially quite a cool option for customizable xslt.
Of course, it requires a lot more knowledge of the source XML.

> my $xslt = XML::LibXSLT->new;
> my $proc = $xslt->parse_stylesheet( $xsl_dom );
> my $rslt = $proc->transform( $xml_dom, p => '//drei' ); # 'node()'
>
> And it also works from the command line using straight xsltproc:
>
> xsltproc --param p '//text()' x.xsl x.xml
>
> That's not possible using Java Xalan or Saxon 6.5 or 9.2.

That was the next step: to worry about getting addicted to
a unique feature! :>

[...]
> On the other hand, I've never used namespaced parameters, though I seem
> to remember they've been recommended to me for use in stylesheets that
> you intend to *distribute* to work as part of some customer's workflow.
> But I've never gotten that far in the first place …

You mean the parameter name itself is namespaced, like $foo:bar ?
I haven't seen that capability anywhere.

[All I'm interested in here, is using namespaces in the XPath expression;
I _could_ rewrite the prefixed expression as Daniel suggests.]

_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs