PLEASE DO NOT REPLY TO THIS MESSAGE. TO FURTHER COMMENT
ON THE STATUS OF THIS BUG PLEASE FOLLOW THE LINK BELOW
AND USE THE ON-LINE APPLICATION. REPLYING TO THIS MESSAGE
DOES NOT UPDATE THE DATABASE, AND SO YOUR COMMENT WILL
BE LOST SOMEWHERE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2862

*** shadow/2862 Fri Jul 27 12:43:54 2001
--- shadow/2862.tmp.2023        Fri Jul 27 12:43:54 2001
***************
*** 0 ****
--- 1,167 ----
+ +============================================================================+
+ | attributes null in for-each on nodes retrieved by document function        |
+ +----------------------------------------------------------------------------+
+ |        Bug #: 2862                        Product: XalanJ2                 |
+ |       Status: NEW                         Version: CurrentCVS              |
+ |   Resolution:                            Platform: All                     |
+ |     Severity: Blocker                  OS/Version: All                     |
+ |     Priority: Other                     Component: org.apache.xalan.xsltc  |
+ +----------------------------------------------------------------------------+
+ |  Assigned To: [EMAIL PROTECTED]                                     |
+ |  Reported By: [EMAIL PROTECTED]                                          |
+ |      CC list: Cc:                                                          |
+ +----------------------------------------------------------------------------+
+ |          URL:                                                              |
+ +============================================================================+
+ |                              DESCRIPTION                                   |
+ This is a regression since XSLTC was donated to Apache. I've been using the
+ following stylesheet in a real-world application to merge two XML documents
+ without duplication. The ID attributes are used to prevent duplicates. The
+ "otherfile" parameter is passed in to reference the other XML document to be
+ merged with the primary XML document being transformed. 
+ 
+ The for-each loop that traverses the nodes in the "otherfile" is working, but
+ for every entry the @ID is null. Doing a value-of select="." shows the expected
+ content of each entry.
+ 
+ Here is the section of the stylesheet where the problem ocurs.
+ 
+   <xsl:for-each select="document(string($otherfile))/calendar/entry">
+ <<<<PRINTING OUT VALUE OF ENTRY NODES HERE IS OK >>>>
+     <xsl:if test="not(contains(string($tbcids),@ID))" >
+ <<<<NEVER GET HERE -- @ID IS ALWAYS NULL MATCHING THE $tbcids string >>>>
+        <xsl:copy-of select="."/>
+        <xsl:text>&#xA;</xsl:text>
+     </xsl:if>
+   </xsl:for-each> 
+ 
+ I've provided the XML from two docs. The transformation should 
+ result in the simple merging of all the entry elements from 
+ both docs, since their ID attributes don't overlap.
+ 
+ XSL (merge.xsl)
+ ===============
+ <xsl:stylesheet version="1.0"
+                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
+ <xsl:param name="otherfile" select="'none'"/>
+ 
+ <!-- otherfile is the calendar.xml file -->
+ <!-- Merge tbc  (to-be-confirmed) and calendar entries, removing duplicates from
+ calendar -->
+ <!-- also used for single entry string buffer as the XML source when editting
+ the entry -->
+ 
+ <!-- Bug in xsltc, xsl:text works as long as no xsl:output element -->
+ <!--<xsl:output method="xml" omit-xml-declaration="yes" />-->
+ 
+ <xsl:template match="calendar">
+ <calendar><xsl:text>&#xA;</xsl:text>
+   <xsl:variable name="tbcids" >
+ <!-- had bug with series, so changed 'entry' to '*' -->
+     <xsl:for-each select="*">
+       <xsl:value-of select="@ID" />
+       <xsl:text> </xsl:text>
+     </xsl:for-each>
+   </xsl:variable>
+    <!-- copy new confirmed entries -->
+   <xsl:apply-templates select="*"/>
+    <!-- copy old entries from master calendar file except duplicates -->
+   <xsl:for-each select="document(string($otherfile))/calendar/entry">
+     <xsl:if test="not(contains(string($tbcids),@ID))" >
+        <xsl:copy-of select="."/>
+        <xsl:text>&#xA;</xsl:text>
+     </xsl:if>
+   </xsl:for-each>
+   <xsl:for-each select="document(string($otherfile))/calendar/series">
+     <xsl:if test="not(contains(string($tbcids),@ID))" >
+        <xsl:copy-of select="."/>
+        <xsl:text>&#xA;</xsl:text>
+     </xsl:if>
+   </xsl:for-each>
+ </calendar>
+ <xsl:text>&#xA;</xsl:text>
+ </xsl:template>
+ 
+ <xsl:template match="*" >
+   <xsl:copy-of select="."/>
+   <xsl:text>&#xA;</xsl:text>
+ </xsl:template>
+ 
+ <!-- turn off the built-in template rules -->
+ <xsl:template match="text()|@*"/>
+ </xsl:stylesheet>
+ 
+ XML (tbc.xml)
+ =============
+ tbc.xml
+ <?xml version="1.0" encoding="iso-8859-1" ?>
+ <calendar>
+ <entry ID="145349" >
+ <user>Tom Amiro</user>
+ <uemail>tamiro@east</uemail>
+ <name>Toms Test of Opening Calendar Tag</name>
+ <date month="8" day="1" year="2001">August 1</date>
+ <distance unit="M" miles="5">5</distance>
+ <time>1:00AM</time><location>5 Empire St</location>
+ <town>Chelmsford</town><state>MA</state><country>USA</country><zip>01824</zip>
+ <contact><address>Tom Amiro, 5 Empire St, Chelmsford,
+ USA</address><phone>978-256-4813</phone></contact>
+ <reslink><title>2000
+ 
+Results</title><url>http://www.coolrunning.com/results/00/ma/lastyr.shtml</url></reslink>
+ <followup><contact>Tom Amiro</contact></followup>
+ </entry>
+ <entry ID="145350" >
+ <user>Tom Amiro</user>
+ <uemail>tamiro@east</uemail>
+ <name>Toms 2nd Test of Opening Calendar Tag</name>
+ <date month="9" day="1" year="2001">September 1</date>
+ <distance unit="M" miles="15">15</distance>
+ <time>1:00AM</time><location>5 Empire St</location>
+ <town>Chelmsford</town><state>MA</state><country>USA</country><zip>01824</zip>
+ <contact><address>Tom Amiro, 5 Empire St, Chelmsford,
+ USA</address><phone>978-256-4813</phone></contact>
+ <reslink><title>2000
+ 
+Results</title><url>http://www.coolrunning.com/results/00/ma/lastyr.shtml</url></reslink>
+ <followup checked="yes"><contact>Tom
+ Amiro</contact><phone>978-256-4813</phone></followup>
+ </entry>
+ </calendar>
+ 
+ XML for otherfile (test.xml)
+ ============================
+ <?xml version="1.0" encoding="utf-8" ?>
+ <calendar>
+ <entry ID="145346" category="kids">
+ <user>Dave Feldhake</user>
+ <uemail>[EMAIL PROTECTED]</uemail>
+ <name>Supersplash 10K/5K and Pool Party</name>
+ <date day="11" year="2001" month="8">August 11</date>
+ <distance miles="6.213712" unit="K">10</distance>
+ <distance miles="3.106856" unit="K">5</distance>
+ <time>8:00AM</time><location>Evergreen Hollow Park</location>
+ <town>Effingham</town><state>IL</state><country>USA</country>
+ <contact>
+ <address>Effingham Park District, PO Box 53, Effingham, IL, USA, 62401</address>
+ <phone>217-342-4415</phone>
+ <email>DJFeldhake@net scape.net</email>
+ </contact>
+ <followup><contact>Dave Feldhake</contact></followup>
+ <crfax>217-342-5680</crfax>
+ </entry>
+ <entry ID="145347">
+ <user>Lin Molloy</user>
+ <uemail>[EMAIL PROTECTED]</uemail>
+ <name>North Aurora Days 10K/5K</name>
+ <date day="4" year="2001" month="8">August 4</date>
+ <distance miles="6.213712" unit="K">10</distance>
+ <distance miles="3.106856" unit="K">5</distance>
+ <time>7:00AM</time><location>Mooseheart</location>
+ <town>North Aurora</town><state>IL</state><country>USA</country>
+ <contact>
+ <address>North Aurora Days, Attn: 5K/10K Run, 1 North Lincolnway, North Aurora,
+ IL, USA, 60542</address>
+ <phone>830-897-8551</phone>
+ </contact>
+ <followup><contact>Lin Molloy</contact></followup>
+ </entry>
+ </calendar>

Reply via email to