[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Temporary Trees and Parser Upgrades

Subject: RE: Temporary Trees and Parser Upgrades
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 11 Apr 2007 00:37:56 +0100
RE:  Temporary Trees and Parser Upgrades
It fails saying

  XTDE1490: Cannot write more than one result document to the same URI, or
write to a URI
  that has been read: file:/c:/MyJava/users/shellenberger/$doi_filename

which is because you have written

<xsl:result-document  href="$doi_filename">

when you meant

<xsl:result-document  href="{$doi_filename}">

It might not have produced that error under 8.8, but I can't see how it can
have "worked" in any meaningful sense when all the output files were written
to the same location.

When I fix that error it fails looking for cat2.xml and article2.xml which
you didn't supply; when I remove those from index.xml, it seems to run
successfully, producing an output file at
file:/c:/projects/working/Playground/10.99990000000000000.xml

(just as well I didn't have anything valuable at that location!)

Incidentally, this is a case where you need the -t option on the command
line to see where your output files have gone.

Michael Kay
http://www.saxonica.com/

 

> -----Original Message-----
> From: Mark Shellenberger [mailto:mshellenberger@xxxxxxxxx] 
> Sent: 10 April 2007 23:10
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Temporary Trees and Parser Upgrades
> 
> XSLT  Gurus,
> 
> I have the following stylesheet that  worked when parsing with Saxon
> 8.8.04 but no longer works with Saxon 8.9.  I  assume this is 
> because some aspect of either xsl:variable or document() was  
> tightened up to the standard and my implementation was 
> sub-standard. The final  goal of this stylesheet is to take 
> in a single lookup table containing file  pairs, combine the 
> category element values of the category file with the entire  
> content of the article in the pair.  The output would have 
> the category elements  as children of the categories element. 
>  The combined structure would be output  with the doi as the filename.
> There will be one output file for each pair of  input 
> documents identified in the lookup table.
> 
> I imagine that this stylesheet is a  wonder of missed 
> opportunities and strangely used structures.  I'd appreciate  
> any constructive comments you have on it.  But, since it 
> worked in Saxon 8.8 and  I now need to use Saxon 8.9, my 
> major concern is figuring out why it no longer  works.
> 
> I leave myself to your tender mercies.
> 
> --Mark
> 
> xslt 2.0  file
> 
> <?xml version="1.0"  encoding="UTF-8"?>
> <xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="2.0">
>     <xsl:output method="xml"  indent="yes"/>
>     <xsl:template  match="//PAIR">
> 
>         <!-- Create variables to  hold documents pointed to 
> from index.xml -->
>         <xsl:variable  name="article" select="document(ARTICLE)"/>
>         <xsl:variable  name="category" select="document(CAT)"/>
> 
>         <!-- 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>
> 
>          <!-- Creates output  directories and filenames -->
>         <xsl:variable  name="doi_filename">
>              <xsl:text>/projects/working/</xsl:text><xsl:value-of
> select="//FOLDER"/><xsl:text>/</xsl:text><xsl:value-of
> select="substring-before($category//doi, '/')"/>
>             <xsl:value-of  select="substring-after($category//doi,
> '/')"/><xsl:text>.xml</xsl:text>
>          </xsl:variable>
> 
>         <!-- Output document with  doi as filename -->
>         <xsl:result-document  href="$doi_filename">
>             <xsl:apply-templates  select="$temp"/>
>          </xsl:result-document>
>     </xsl:template>
> 
>    <!-- output category elements  as children of 
> article-meta/categories element  -->
>     <xsl:template  match="//article-meta//categories">
>          <xsl:copy>
>            <xsl:apply-templates
> select="//article-meta/following-sibling::categories//category"/>
>          </xsl:copy>
>      </xsl:template>
> 
>      <!-- Drop all category  elements -->
>     <xsl:template  match="/categories"/>
> 
>      <!-- Identity Transform  -->
>     <xsl:template  match="node()|@*">
>          <xsl:copy>
>             <xsl:apply-templates  select="@*"/>
>              <xsl:apply-templates/>
>          </xsl:copy>
>      </xsl:template>
> </xsl:stylesheet>
> 
> Index.xml
> <INDEX>
>      <WORKFOLDER>C:</WORKFOLDER>
>      <FOLDER>Playground</FOLDER>
>      <PAIRS>
>          <PAIR>
>              <ARTICLE>article1.xml</ARTICLE>
>              <CAT>cat1.xml</CAT>
>          </PAIR>
>          <PAIR>
>              <ARTICLE>article2.xml</ARTICLE>
>              <CAT>cat2.xml</CAT>
>          </PAIR>
>      </PAIRS>
> </INDEX>
> 
> Cat1.xml:
> <article-category>
>                  <doi>10.9999/0000000000000</doi>
>                  <categories>
>                                 <category>Jungle Gyms</category>
>                                  <category>Swing Sets</category>
>                                  <category>Monkey Bars</category>
>                                  <category>Slides</category>
>                  </categories>
> </article-category>
> 
> 
> Article1.xml
> <root doi="10.9999/0000000000000"  type="journal">
>      <header>
>          <journal-meta>
>             <title>Journal of  Playgrounds</title>
>              <ISSN>0000-000x</ISSN>
>              <volume>1</volume>
>              <issue>4</issue>
>              <date>
>                  <year>2003</year>
>                  <month>June</month>
>              </date>
>              <publication>
>                 <name>Me  Enterprises</name>
>                  <location>Springfield, Simpson State</location>
>              </publication>
>          </journal-meta>
>          <article-meta>
>             <title>Playground  Equipment</title>
>              <subtitle>Alternative Methods and  Conclusions</subtitle>
>              <author>
>                  <person>
>                      <firstname>Bob</firstname>
>                      <middle>J.</middle>
>                      <surname>Smith</surname>
>                      <aff>University of Pennsylvania</aff>
>                  </person>
>              </author>
>              <startpage>98</startpage>
>              <finishpage>119</finishpage>
>              <categories/>
>          </article-meta>
>      </header>
>      <body>     </body>
>      <references>    </references>
>      </root>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.