Re: [xsl] Re: Performance observation.
Ihe Onwuka <[email protected]> Wed, 9 Sep 2020 03:04:13 -0400
| Newsgroups | gmane.text.xml.saxon.help,gmane.text.xml.xsl.general.mulberrytech |
|---|---|
| Message-ID | <CALfs7+zi_n58B5toiMFNCn=3eKic2Ramr+Wkr4QLVFW0DY9SQA@mail.gmail.com> |
However where-populated can't doing the same job as try catch here because the stylesheet just errored with an attempt to create a namespace node with a blank namespace uri. On Tue, Sep 8, 2020 at 7:37 AM Ihe Onwuka <[email protected]> wrote: > xsl:where-populated fluctuates as high as the try catch but at best there > is no performance penalty. > > > On Tue, Sep 8, 2020 at 6:19 AM Michael Kay mike-JkSD5nQpfvpWk0Htik3J/[email protected] < > xsl-list-service-VWJlPdIPk9umXcTjhJAOxCoMnp2j79Jp@public.gmane.org> wrote: > >> I'm slightly suprised by the performance effect but it depends how often >> the pattern is matched, and what other patterns are present in the >> stylesheet. Certainly putting complex logic into patterns can be risky from >> a performance point of view. >> >> How about using xsl:where-populated rather than xsl:try? >> >> Michael Kay >> Saxonica >> >> On 8 Sep 2020, at 08:16, Ihe Onwuka <[email protected]> wrote: >> >> The goal is to create a namespace node if the value of xsi:type is a >> QName. >> >> The code here simulates the situation >> >> https://xsltfiddle.liberty-development.net/a9HjZj >> >> The problem is that this fails if the select evaluates to the empty >> string. >> >> <xsl:template match="@xsi:type"> >> <xsl:namespace name="{substring-before(.,':')}" >> select="$schemas/thing/@targetNamespace"/> >> <xsl:next-match/> >> </xsl:template> >> >> Now in the real code the select is actually a key retrieval so looks more >> like this >> >> <xsl:template match="@xsi:type"> >> <xsl:namespace name="{substring-before(.,':')}" >> select="key('myKey',.,$schemas)/@targetNamespace"/> >> <xsl:next-match/> >> </xsl:template> >> >> So in order to avoid failure I tried this >> >> <xsl:template match="@xsi:type[ >> key('myKey',.,$schemas)/@targetNamespace => normalize-space()]"> >> <xsl:namespace name="{substring-before(.,':')}" >> select="key('myKey',.,$schemas)/@targetNamespace"/> >> <xsl:next-match/> >> </xsl:template> >> >> now that works but quadrupled the execution time of the stylesheet. >> >> Doing it with try catch >> >> <xsl:template match="@xsi:type"> >> <xsl:try> >> <xsl:namespace name="{substring-before(.,':')}" >> select="key('myKey',.,$schemas)/@targetNamespace"/> >> <xsl:catch/> >> </xsl:try> >> <xsl:next-match/> >> </xsl:template> >> >> is a teenie bit quicker. >> >> Overall execution time is still tolerable so posting this as an >> observation. >> >> For the XSL list >> >> Is there a way to code >> >> <xsl:template match="@xsi:type[ >> key('myKey',.,$schemas)/@targetNamespace => normalize-space()]"> >> <xsl:namespace name="{substring-before(.,':')}" >> select="key('myKey',.,$schemas)/@targetNamespace"/> >> <xsl:next-match/> >> </xsl:template> >> >> without repeating the code for the key access thats on the template rule >> predicate inside the template rule. >> >> >> >> >> >> _______________________________________________ >> saxon-help mailing list archived at http://saxon.markmail.org/ >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/saxon-help >> >> >> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> >> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/601651> (by >> email <[email protected]?subject=remove>) >> > _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [email protected] https://lists.sourceforge.net/lists/listinfo/saxon-help