xsl-list
[Top] [All Lists]

RE: [xsl] Temporary Trees and Parser Upgrades

2007-04-10 17:22:17
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(_at_)nag(_dot_)co(_dot_)uk] 
Sent: Tuesday, April 10, 2007 8:10 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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>

--~------------------------------------------------------------------
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>
--~--


--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>