• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Help on XSL XPath

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to xsl development , however I am determined to work on xsl porting project from Xalan interpretive to xalan compiled processor.

cut short version template is given below. app.xsl references generic.xsl and makes a template call with parameters. because I am trying to learn too many
things at a time , i am finding difficulty in replacing xalan:evalaute() function with standard XPath predicates.

Please help me with some clues on replacing xalan:evalaute with standard XPath expressions. Also some guidence to gain sufficient knowledge to replace such a calls made in several other places in
the entire project.

I am using xsltc for converting these static xsl files into translet for performance reasons. So there was a need for replacement of evalaute calls

Thanks & Regards,
Amar
app.xsl

<xsl:call-template name="mySelectFieldNew">
<xsl:with-param name="OptionPath">/WMS/wms_ref_annc_id/Row</xsl:with-param>
<xsl:with-param name="Value">value</xsl:with-param>
<xsl:with-param name="Display">display</xsl:with-param>
</xsl:call-template>

<xsl:call-template name="mySelectFieldNew">
<xsl:with-param name="OptionPath">/WMS/wms_ref_pref_lang/Row</xsl:with-param>
<xsl:with-param name="Value">value</xsl:with-param>
<xsl:with-param name="Display">display</xsl:with-param>
</xsl:call-template>

generic.xsl:

<xsl:template name="mySelectFieldNew">
<xsl aram name="OptionPath" select="$default"/>
<xsl aram name="Value" select="$default-value"/>
<xsl aram name="Display" select="$default-display"/>
<xsl aram name="Sort" select="'off'"/>
<xsl aram name="SelectedValuePath" select="$default"/>
<xsl aram name="ConstantSelectedValuePath" select="$default"/>

<xsl:choose>
<xsl:when test="not($OptionPath=$default)">
<xsl:choose>
<xsl:when test="$Sort = 'on'"> <!-- sorted -->
<xsl:for-each select="xalan:evaluate($OptionPath)">
<xsl:sort select="xalan:evaluate($Display)"/>
<option>
<xsl:if test="not($SelectedValuePath=$default and $ConstantSelectedValuePath=$default)">
<xsl:if test="$selectVal = xalan:evaluate($Value)">
<xsl:attribute name="selected"/>
</xsl:if>
</xsl:if>

<xsl:attribute name="value">
<xsl:value-of select="xalan:evaluate($Value)"/>
</xsl:attribute>
<xsl:value-of select="xalan:evaluate($Display)"/>
</option>
</xsl:for-each>
</xsl:when>
<xsl therwise> <!-- unsorted -->
<xsl:for-each select="xalan:evaluate($OptionPath)">
<option>
<xsl:if test="not($SelectedValuePath=$default and $ConstantSelectedValuePath=$default)">
<xsl:if test="$selectVal = xalan:evaluate($Value)">
<xsl:attribute name="selected"/>
</xsl:if>
</xsl:if>

<xsl:attribute name="value">
<xsl:value-of select="xalan:evaluate($Value)"/>
</xsl:attribute>
<xsl:value-of select="xalan:evaluate($Display)"/>
</option>
</xsl:for-each>
</xsl therwise>
</xsl:choose>
</xsl:when>
<xsl therwise>

<xsl:template>
 
Sheriff
Posts: 28333
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I'm not mistaken, xalan:evaluate will take a string and evaluate it as if it were an XPath expression. It exists specifically because XSLT doesn't provide that ability.

So there's no easy way to get rid of it, especially if (as in your example) you have unrestricted input strings. It would theoretically be possible to write an XPath parser and interpreter, but XSLT would not be my first choice of language for that. Budget several months for an XSLT expert to do that. And expect much worse performance from it than from xalan:evaluate.
 
author
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From XSLT you can call Java Functions.

look at this article: HSLT with JAVA
 
I need a new interior decorator. This tiny ad just painted every room in my house purple.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic