Home
TeamSite
pass parameter to <iwov_xslt>
sara
Hi
How can I pass a parameter to the xsl in the <iwov_xslt> tag?
in the tpl, i call the xsl file with
<iwov_xslt xsl_file="hello.xsl" mode="ptlocal">
<iw_value name="$xml"/>
</iwov_xslt>
where $xml is an xml string.
I would like to call a different template depending on the parameter passed to the xsl. How can I pass a parameter to the xsl?
thx
s
Find more posts tagged with
Comments
Gregg Faus
It doesn't look like this tag will support a XSL parameter being passed to it. You'll have to resort to using inline PERL code to apply the transformation with a parameter. Looks like the XML::XSLT module would do it.
sara
where can I find some documentation on XML::XSLT? perldoc does not return anything.
s
sara
and do you have any suggestions on using regexes within an xsl?
Gregg Faus
Well here is CPAN's documentation:
http://search.cpan.org/author/JSTOWE/XML-XSLT-0.40/lib/XML/XSLT.pm
A bit confusing, you may want to find another resource. I don't have any off hand since I don't use perl to transform XML.
To answer you reg'ex problem. XSLT doesn't support regular expressions. I've done a lot of XSLT and have never needed them directly in a template. You may want to explain why you need them and maybe someone can offer an alternative.
sara
- passing parameters to XSL
That XSLT module does not offer all possibilities of XSLT. I found a workaround: before the XML is passed to the XSLT, I added an attribute to the root element, which is used as a parameter in the XSLT.
- using regexes in XSL
I am creating a navigation menu with a DCT. Different files are generated to represent the different levels of the menu, these files link to each other to represent the navigation in the menu.
The pages are created with the names of the navigation levels. these filenames are passed to some regexes to eliminate some illegal characters.
the xsl that fills the content of these pages need to add links to the other pages. Thus the links must pass the same regexes.
I have thought of one workaround (not implemented yet): with formapi I can add extra elements in the dct, representing the modified file name. These elements would then be used in the xsl
any other suggestions?
sara
Gregg Faus
There is an XSLT module that would of done parameter passing -- there's gotta be. Anyway, glad you found a workaround.
Instead of using a regex to eliminate your illegal characters couldn't you use the translate XSL function?
For example, this would translate (remove) some special characters from the node $value.
<xsl:value-of select="translate($value, '~!
@#$%^&
;*()[]', '')" />