Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Performance referencing global parameter data

From: "Richard Collette" <richard.collette@-----.--->
To: NULL
Date: 1/3/2007 12:08:00 PM

Dimitre,

Just wrote the parameter this way just to show typical contents. In
fact, the parameter will be dynamic.  Otherwise I would have just
declared a global variable.  Any thoughts considering it is a dynamic
parameter?

Thanks,
Rich


Dimitre Novatchev wrote:
> <richard.collette@g...> wrote in message
> news:1167847756.234534.79320@h......
> > To the best of my knowledge, there is no way in XSL 1.0 to key values
> > passed in a global parameter since xsl:key will not accept variables.
> > So I am left with the worst performing aspect of my xsl being lookups
> > to parameterized configuration information which looks like:
> >
> > <xsl:param name="config">
> >  <documentType miscControlAttributes="">
> >     <itemName miscControlAttributes=""/>
> >     <itemName2 miscControlAttributes=""/>
> >  </documentType>
> > </xsl:param>
> >
> > The configuration is then stored as a nodeset
> > <xsl:variable name="configuration-nodeset"
> > select="msxsl:node-set($configuration)"/>
>
> This is not necessary for static (not dynamically generated parameters). One
> can simply write:
>
>
> <xsl:variable name="configuration-nodeset"
>         select="document('')/*/xsl:param[@name='config'"/>
>
> >
> > For each documentType node in the input, I retrieve the document level
> > configuration into a variable:
> > <xsl:variable name="documentConfiguration"
> > select="$configuration-nodeset/*[translate(name(), $lc,
> > $uc)=translate(current()/@form,$lc,$uc)]"/>
> >
> > The document nodes are, unfortunately, case insensitive coming from the
> > source, so I have to perform a translation to upper case for
> > comparison.
> >
> > The template for processing document items is called, passing in the
> > document configuration
> > <xsl:apply-templates select="*">
> >  <xsl:with-param name="documentConfiguration"
> > select="$documentConfiguration"/>
> > </xsl:apply-templates>
> >
> > The document item template then does a lookup to the item configuration
> > <xsl:template match="d:item">
> >  <xsl:param name="documentConfiguration"/>
> >  <xsl:variable name="itemConfiguration"
> > select="$documentConfiguration/*[translate(name(),$lc,$uc)=translate($normalizedElementName,$lc,$uc)]"/>
> > </xsl:template>
> >
> > Does anyone know of a better pattern for looking up parameterized
> > configuration info that is compatible with XSL 1.0?
> >
>
> The key() function operates on the current document. This means that xsl:key
> can be used to index any document, including a dynamically created one.
>
> This design pattern is well known and can be implemented as in the example
> below:
>
>    <xsl:for-each select="<root-node-of-some-document"> <!-- makes
> <some-document> the current document -->
>
>      <xsl:for-each select="key('some-key', <some-value>)"> <!-- Creates an
> index for the given key the first time it is referenced by a key() function
> for the current document -->
>
>         <!-- do whatever is necessary with each node selected by the key()
> function -->
>
>      </xsl:for-each>
>    </xsl:for-each>
>
> For more examples do have a look at:
>   http://dpawson.co.uk/xsl/sect2/N4852.html#d5954e181
>
> and generally at:
>   http://dpawson.co.uk/xsl/sect2/N4852.html
> 
> 
> Hope this helped.
> 
> Cheers,
> Dimitre Novatchev



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent