Subject: RE: [xsl] Temporary Trees and Parser Upgrades From: "Mark Shellenberger" <mshellenberger@xxxxxxxxx> Date: Tue, 10 Apr 2007 20:21:48 -0400 |
Thank you Michael and David, The missing '{}' was a typo when I was taking out specifics in order to post to the list. The same can be said of the missing cat2.xml, etc content. I don't know why Michael was able to make it work. My fear is that I 'fixed' it accidentally when typing it for the list. I greatly appreciate you both taking the time to mess with it and for David to provide such clear examples of elements I have not had the opportunity to try out before. I have a lot to digest. --Mark -----Original Message----- From: David Carlisle [mailto:davidc@xxxxxxxxx] Sent: Tuesday, April 10, 2007 8:10 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Temporary Trees and Parser Upgrades > 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, David Carlisle | Thread | RE: [xsl] Temporary Trees and Parse, Michael Kay |
Re: [xsl] Temporary Trees and Parse, David Carlisle | Date | [xsl] Writing a SELECT with each OP, Waters, Tyler S FOR: |
Month |