Subject: Re: [xsl] Processing 2 files and using one with key() lookups? From: "David Carlisle d.p.carlisle@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 27 Oct 2015 17:03:55 -0000 |
On 27 October 2015 at 16:43, dvint@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > I've run into a couple of odd problems trying to use keys and I guess I > have never processed 2 files where one is there to just be used to lookup > values. > > First problem > > So one file is the one that drives the processing. I was using this as the > input to my stylesheet and using the document() function to read the > second one and build my keys. This was failing when I tried this: > > <xsl:param name="QAREPORTname" select="_dan1385156030824-qa.dita"/> > <xsl:variable name="QAREPORT" select="document($QAREPORTname, /)"/> > > <xsl:key name="TOPIC" match="$QAREPORT/data[@name='WDtopicID']" > use="."/> > > or > > <xsl:key name="TOPIC" match="document($QAREPORTname, > /)/data[@name='WDtopicID']" use="."/> > > or > > <xsl:key name="TOPIC" match="document(_dan1385156030824-qa.dita, > /)/data[@name='WDtopicID']" use="."/> > that would only match id data was the document element, and uses the string value of the whole document as key. keys apply (conceptually) to all files so <xsl:key name="TOPIC" match="data[@name='WDtopicID']" use="."/> > I couldn't find a way to make this work, so my workaround was to feed the > reference document to the stylesheet and then read in the driver file and > continue processing. Seems to work but lead to the next problem > > Second problem > > The key definition seems to get lost when I do the following: > > <xsl:template match="/"> > <xsl:copy-of select="key('TOPIC', 'dan1370798005424')"/> > <!-- Force processing to continue with the second file --> > <xsl:apply-templates select="$FLATMAP" mode="map"/> > </xsl:template> You need to specify the document at this point key('TOPIC',, 'dan1370798005424',$QAREPORT)"/> or in XSLT1 $QAREPORT/key('TOPIC', 'dan1370798005424') > > <xsl:template match="/" mode="map"> > <xsl:apply-templates mode="map"/> > </xsl:template> > > > <xsl:template match="topicref" mode="map"> > <topicref> > <xsl:copy-of select="key('TOPIC', 'dan1370798005424')"/> > </topicref> > </xsl:template> > > What I'm seeing is that the copy-of statement in the template matching '/' > with no mode gives me the correct result. When the same statement is used > in the match for 'topicref' I get no match or content generated. > > Question: > > - Can you explain why the key() doesn't work in the template with the mode > and give me a correction/workaround? > > - I'd really like to go back to the more natural processing order and get > rid of the modes on the templates. Is there some way to get my key > definition to process a file that isn't the input? David
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Processing 2 files and using , dvint@xxxxxxxxx | Thread | Re: [xsl] Processing 2 files and us, David Carlisle d.p.c |
[xsl] Processing 2 files and using , dvint@xxxxxxxxx | Date | Re: [xsl] Processing 2 files and us, David Carlisle d.p.c |
Month |