xsl-list
[Top] [All Lists]

Re: [xsl] AVT use and doc() function in xslt 2.0?

2011-08-19 03:45:18
On 18 August 2011 22:00,  <dvint(_at_)dvint(_dot_)com> wrote:
Interesting idea, but I'm not sure I can appli it in the final case. I
actually have multiple levels I need to match. This is what my code looks
like currently:

<xsl:variable name="lookup"
select="doc('dmcmapping.xml')/searchReplace/smodelic[@val=current()/modelic]/ssdc[@val=current()/sdc]/schapnum[@val=current()/chapnum]/ssection[@val=current()/section]/ssubsect[@val=current()/subsect]/ssubject[@val=current()/subject]/sdiscode[@val=current()/discode]/sdiscodev[@val=current()/discodev]/sincode[@val=current()/incode]/sincodev[@val=current()/incodev]/sitemloc[@val=current()/itemloc]/replaceWith"/>

<xsl:copy-of select="$lookup/modelic"/>
<xsl:copy-of select="$lookup/sdc"/>
<xsl:copy-of select="$lookup/chapnum"/>
<xsl:copy-of select="$lookup/section"/>
<xsl:copy-of select="$lookup/subsect"/>
<xsl:copy-of select="$lookup/subject"/>
<xsl:copy-of select="$lookup/discode"/>
<xsl:copy-of select="$lookup/discodev"/>
<xsl:copy-of select="$lookup/incode"/>
<xsl:copy-of select="$lookup/incodev"/>
<xsl:copy-of select="$lookup/itemloc"/>

What I have is one really long key stored in multiple elements and
attributes. Now I control the lookup file format, so I might be able to
concatenate all the values into a single key and then change my template
accordingly.

You could change the key to be all of the @val attributes joined using a hyphen:

match="replaceWith" use="string-join((ancestor::* except
searchReplace)/@val, '-')"

then you should be able to call using the much shorter:

key('blah', string-join((modelic,sdc,chapnum,....), ','), $doc)

which if they are in document order anyway then just:

key('blah', string-join(*, ','), $doc)

This is for a conversion effort and ultimatley it should be throwaway
code. I just ran the process on 127 documents/files and it ran pretty fast
with the above.

Ironically 'throwaway' code often hangs around for long time...


-- 
Andrew Welch
http://andrewjwelch.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--