Subject: Re: [xsl] Temporary Trees and Parser Upgrades From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 11 Apr 2007 01:09:49 +0100 |
> but no longer works with Saxon 8.9. it's usually best to say what happens: error message, core dump, loops forever, etc. If I run your code I get $ saxon8 catindex.xml catindex.xsl Error at xsl:apply-templates on line 48 of file:/c:/tmp/catindex.xsl: XTDE1490: Cannot write more than one result document to the same URI, or write to a URI that has been read: file:/c:/tmp/$doi_filename Transformation failed: Run-time errors were reported which shows that its writing a file with name $doi_filename which wasn't what you wanted, you wanted that variable expanding. You need AVT syntax <xsl:result-document href="{$doi_filename}"> for that. Are you sure that worked in 8.8?? Then it works (I think) but seems to be very inefficient. <!-- Create temporary tree with entire article and descendents of the categories element --> <xsl:variable name="temp"> <xsl:apply-templates select="$article|$category//categories"/> </xsl:variable> That isn't the entire article it's a copy of the article, I don't see why you need a copy, and can't apply templates to the original nodes? Also as a general rule avoid // it searches the document to arbitrary depth, even if as here you know all the categories are at the same level. <xsl:value-of select="substring-after($category//doi, same comment about // <xsl:template match="//article-meta//categories"> and here, except the additional comment that you dn't need // at the front of a match pattern (it doesn't change the nodes matched). <xsl:template match="//PAIR"> again. If I understand correctly what you want do do I'd do <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes"/> <xsl:variable name="path" select="concat('/projects/working/',INDEX/FOLDER,'/')"/> <xsl:template match="INDEX"> <xsl:for-each select="PAIRS/PAIR"> <xsl:apply-templates select="doc(ARTICLE)"> <xsl:with-param name="pair" select="." tunnel="yes"/> </xsl:apply-templates> </xsl:for-each> </xsl:template> <xsl:template match="root"> <xsl:result-document href="{$path}{translate(@doi,'/','')}.xml"> <xsl:next-match/> </xsl:result-document> </xsl:template> <xsl:template match="categories"> <xsl:param name="pair" tunnel="yes"/> <xsl:copy-of select="doc($pair/CAT)/article-category/categories"/> </xsl:template> <!-- Identity Transform --> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Temporary Trees and Parse, Michael Kay | Thread | RE: [xsl] Temporary Trees and Parse, Mark Shellenberger |
RE: [xsl] Temporary Trees and Parse, Michael Kay | Date | RE: [xsl] Temporary Trees and Parse, Mark Shellenberger |
Month |