dmarston    2002/12/02 13:16:22

  Modified:    test/tests/conf/idkey idkey51.xsl idkey31.xsl idkey49.xml
                        idkey49.xsl idkey49a.xml idkey49c.xml idkey51.xml
                        idkey31.xml
  Log:
  Convert to processor-independent form.
  String compares happen internally.
  
  Revision  Changes    Path
  1.2       +35 -14    xml-xalan/test/tests/conf/idkey/idkey51.xsl
  
  Index: idkey51.xsl
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/tests/conf/idkey/idkey51.xsl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- idkey51.xsl       17 Dec 2001 14:27:34 -0000      1.1
  +++ idkey51.xsl       2 Dec 2002 21:16:22 -0000       1.2
  @@ -1,4 +1,4 @@
  -<?xml version="1.0" encoding="ISO-8859-1"?>
  +<?xml version="1.0" encoding="UTF-8"?>
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
   
     <!-- FileName: idkey51 -->
  @@ -11,21 +11,42 @@
       Retrieving the name from the principal XML document should still clearly mean 
the
       same file. Putting nodes in a variable is more of a gray area. -->
   
  +<xsl:output method="xml" encoding="UTF-8" indent="no"/>
  +
   <xsl:template match="doc">
     <out>
  -    <xsl:variable name="nodes" select="document('idkey49b.xml')//body" />
  -    <xsl:text>&#10;</xsl:text>
  -    <from-a>
  -      <xsl:for-each select="document(a)//body">
  -        <xsl:value-of select="generate-id(.)"/><xsl:text>,  </xsl:text>
  -      </xsl:for-each>
  -    </from-a>
  -    <xsl:text>&#10;</xsl:text>
  -    <from-v>
  -      <xsl:for-each select="$nodes">
  -        <xsl:value-of select="generate-id(.)"/><xsl:text>,  </xsl:text>
  -      </xsl:for-each>
  -    </from-v>
  +    <xsl:variable name="tn" select="document('idkey49a.xml')//doc/body/text()[1]" />
  +    <xsl:choose>
  +      <xsl:when test="generate-id(document('idkey49a.xml')//body) != 
generate-id(document(a)//body)">
  +        <xsl:text>FAIL on body element: </xsl:text>
  +        <xsl:value-of 
select="generate-id(document('idkey49c.xml')//body)"/><xsl:text>,  </xsl:text>
  +        <xsl:value-of 
select="generate-id(document(a)//body)"/><xsl:text>&#10;</xsl:text>
  +      </xsl:when>
  +      <xsl:when test="generate-id(document('idkey49a.xml')//text()[1]) != 
generate-id(document(a)//text()[1])">
  +        <xsl:text>FAIL on first text node: </xsl:text>
  +        <xsl:value-of 
select="generate-id(document('idkey49c.xml')//text()[1])"/><xsl:text>,  </xsl:text>
  +        <xsl:value-of 
select="generate-id(document(a)//text()[1])"/><xsl:text>&#10;</xsl:text>
  +      </xsl:when>
  +      <xsl:when test="generate-id(document('idkey49a.xml')//body/@att) != 
generate-id(document(a)//body/@att)">
  +        <xsl:text>FAIL on body attribute: </xsl:text>
  +        <xsl:value-of 
select="generate-id(document('idkey49c.xml')//body/@att)"/><xsl:text>,  </xsl:text>
  +        <xsl:value-of 
select="generate-id(document(a)//body/@att)"/><xsl:text>&#10;</xsl:text>
  +      </xsl:when>
  +      <xsl:when test="generate-id(document('idkey49a.xml')//comment()[1]) != 
generate-id(document(a)//comment()[1])">
  +        <xsl:text>FAIL on first comment node: </xsl:text>
  +        <xsl:value-of 
select="generate-id(document('idkey49c.xml')//comment()[1])"/><xsl:text>,  </xsl:text>
  +        <xsl:value-of 
select="generate-id(document(a)//comment()[1])"/><xsl:text>&#10;</xsl:text>
  +      </xsl:when>
  +      <!-- Now try the node in the variable -->
  +      <xsl:when test="generate-id($tn) != 
generate-id(document(a)//doc/body/text()[1])">
  +        <xsl:text>FAIL on inner text node: </xsl:text>
  +        <xsl:value-of 
select="generate-id(document('idkey49c.xml')//text()[1])"/><xsl:text>,  </xsl:text>
  +        <xsl:value-of 
select="generate-id(document(a)//text()[1])"/><xsl:text>&#10;</xsl:text>
  +      </xsl:when>
  +      <xsl:otherwise>
  +        <xsl:text>Success</xsl:text>
  +      </xsl:otherwise>
  +    </xsl:choose>
     </out>
   </xsl:template>
   
  
  
  
  1.3       +69 -11    xml-xalan/test/tests/conf/idkey/idkey31.xsl
  
  Index: idkey31.xsl
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/tests/conf/idkey/idkey31.xsl,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- idkey31.xsl       31 Jan 2001 22:36:26 -0000      1.2
  +++ idkey31.xsl       2 Dec 2002 21:16:22 -0000       1.3
  @@ -1,4 +1,4 @@
  -<?xml version="1.0"?>
  +<?xml version="1.0" encoding="UTF-8"?>
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
   
     <!-- FileName: idkey31 -->
  @@ -7,22 +7,80 @@
     <!-- Section: 12.4 Miscellaneous Additional Functions  -->
     <!-- Creator: David Marston -->
     <!-- Purpose: Test of 'generate-id()' on namespace nodes -->
  -  <!-- Results will vary by processor. -->
  +
  +<xsl:output method="xml" encoding="UTF-8" indent="no"/>
   
   <xsl:template match="/">
     <out>
  -    <xsl:apply-templates/>
  +  <!-- Build up a string containing generated IDs for nodes on the namespace axes 
of self and all lower elements. -->
  +  <xsl:variable name="accumulated">
  +    <!-- Since call-template doesn't change context, iterate by position number. -->
  +    <xsl:call-template name="nextnode">
  +      <xsl:with-param name="this" select="1" />
  +      <xsl:with-param name="max" select="count(descendant-or-self::*/namespace::*)" 
/>
  +      <xsl:with-param name="idset" select="'+'" />
  +      <!-- Use + as delimiter to avoid spoofs from adjacent strings.
  +           Returned string from generate-id() can't contain +. -->
  +    </xsl:call-template>
  +  </xsl:variable>
  +  <!-- Summary data, so we have output when we pass. -->
  +  <xsl:text>Number of IDs accumulated: </xsl:text>
  +  <xsl:value-of select="count(descendant-or-self::*/namespace::*)"/>
  +  <!-- Now, take one node of each kind, whose generated ID should not be in the 
accumulated string,
  +    surround generated ID by + to avoid substring matches, and see if it's in 
there. -->
  +  <!-- Now see if we duplicated an ID with the root -->
  +  <xsl:if test="contains($accumulated,concat('+',generate-id(/),'+'))">
  +    <xsl:text>FAIL on root node whose ID is </xsl:text>
  +    <xsl:value-of select="generate-id(/)"/>
  +  </xsl:if>
  +  <!-- Now see if we duplicated an ID with the element -->
  +  <xsl:if test="contains($accumulated,concat('+',generate-id(.),'+'))">
  +    <xsl:text>FAIL on side node whose ID is </xsl:text>
  +    <xsl:value-of select="generate-id(.)"/>
  +  </xsl:if>
  +  <!-- Now see if we duplicated an ID with the attribute -->
  +  <xsl:if test="contains($accumulated,concat('+',generate-id(./@att),'+'))">
  +    <xsl:text>FAIL on side/@att node whose ID is </xsl:text>
  +    <xsl:value-of select="generate-id(./@att)"/>
  +  </xsl:if>
  +  <!-- Now see if we duplicated an ID with the text node -->
  +  <xsl:if test="contains($accumulated,concat('+',generate-id(./text()),'+'))">
  +    <xsl:text>FAIL on side/text() node whose ID is </xsl:text>
  +    <xsl:value-of select="generate-id(./text())"/>
  +  </xsl:if>
  +  <!-- Now see if we duplicated an ID with the comment node -->
  +  <xsl:if test="contains($accumulated,concat('+',generate-id(./comment()),'+'))">
  +    <xsl:text>FAIL on side/comment() node whose ID is </xsl:text>
  +    <xsl:value-of select="generate-id(./comment())"/>
  +  </xsl:if>
  +  <!-- Now see if we duplicated an ID with the PI node -->
  +  <xsl:if 
test="contains($accumulated,concat('+',generate-id(./processing-instruction('s-pi')),'+'))">
  +    <xsl:text>FAIL on side/processing-instruction('s-pi') node whose ID is 
</xsl:text>
  +    <xsl:value-of select="generate-id(./processing-instruction('s-pi'))"/>
  +  </xsl:if>
     </out>
   </xsl:template>
   
  -<xsl:template match="*">
  -  <xsl:element name="{name(.)}">
  -    <xsl:for-each select="namespace::*">
  -     <xsl:sort/>
  -    <xsl:element name="{name(.)}"><xsl:value-of 
select="generate-id()"/></xsl:element>
  -  </xsl:for-each>
  -  </xsl:element>
  -  <xsl:apply-templates/>
  +<xsl:template name="nextnode">
  +  <xsl:param name="this"/>
  +  <xsl:param name="max"/>
  +  <xsl:param name="idset"/>
  +  <!-- Params this and max are index numbers, idset is the string we're 
accumulating. -->
  +  <xsl:variable name="this-id" 
select="generate-id((descendant-or-self::*/namespace::*)[position() = $this])"/>
  +  <xsl:choose>
  +    <xsl:when test="$this &lt;= $max">
  +      <!-- Recurse, adding current ID to string of all IDs of namespace nodes, with 
separators -->
  +      <xsl:call-template name="nextnode">
  +        <xsl:with-param name="this" select="$this+1" />
  +        <xsl:with-param name="max" select="$max" />
  +        <xsl:with-param name="idset" select="concat($idset,$this-id,'+')" />
  +      </xsl:call-template>
  +    </xsl:when>
  +    <xsl:otherwise>
  +      <!-- "return" the final idset -->
  +      <xsl:value-of select="$idset"/>
  +    </xsl:otherwise>
  +  </xsl:choose>
   </xsl:template>
   
   </xsl:stylesheet>
  
  
  
  1.4       +2 -4      xml-xalan/test/tests/conf/idkey/idkey49.xml
  
  Index: idkey49.xml
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/tests/conf/idkey/idkey49.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- idkey49.xml       1 Aug 2001 19:05:49 -0000       1.3
  +++ idkey49.xml       2 Dec 2002 21:16:22 -0000       1.4
  @@ -1,9 +1,7 @@
  -<?xml version="1.0" encoding="ISO-8859-1"?>
  +<?xml version="1.0" encoding="UTF-8"?>
   <doc>
  -  <a/>
  -  <a>idkey49a.xml</a><!-- Hello -->
  +  <side att="view"><!-- This is the side comment -->text-in-side<?s-pi side 
?></side>
     <a>idkey49b.xml</a><!-- Shirt, Overt -->
     <a>idkey49c.xml</a><!-- GoodBye -->
     <a>idkey49d.xml</a><!-- Tie, Sly -->
  -  <x/>
   </doc>
  
  
  
  1.5       +104 -15   xml-xalan/test/tests/conf/idkey/idkey49.xsl
  
  Index: idkey49.xsl
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/tests/conf/idkey/idkey49.xsl,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- idkey49.xsl       29 Oct 2001 17:08:36 -0000      1.4
  +++ idkey49.xsl       2 Dec 2002 21:16:22 -0000       1.5
  @@ -1,28 +1,117 @@
  -<?xml version="1.0" encoding="ISO-8859-1"?>
  +<?xml version="1.0" encoding="UTF-8"?>
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
   
     <!-- FileName: idkey49 -->
     <!-- Document: http://www.w3.org/TR/xslt -->
     <!-- DocVersion: 19991116 -->
     <!-- Section: 12.4 Generate-ID  -->
  -  <!-- Creator: Paul Dick -->
  -  <!-- Purpose: Test generate-id() when nodes are coming from different
  -    documents. All id's should be distinct. The first for-each
  -    prints out info about the document and node value. The
  -    second loop prints out the id. -->
  +  <!-- Creator: David Marston -->
  +  <!-- Purpose: Test generate-id() when nodes are coming from different documents.
  +    All IDs should be distinct. -->
  +
  +<xsl:output method="xml" encoding="UTF-8" indent="no"/>
   
   <xsl:template match="doc">
     <out>
  -   <values>
  -    <xsl:for-each select="document(a)//body">
  -      <xsl:value-of select="."/><xsl:text>,  </xsl:text>
  -    </xsl:for-each></values>
  -    <xsl:text>&#10;</xsl:text>
  -   <ids>
  -    <xsl:for-each select="document(a)//body">
  -      <xsl:value-of select="generate-id(.)"/><xsl:text>,  </xsl:text>
  -    </xsl:for-each></ids>
  +    <!-- Get in position so we have nodes on the following axis. -->
  +    <xsl:apply-templates select="side"/>
     </out>
  +</xsl:template>
  +
  +<xsl:template match="side">
  +  <!-- Build up a string containing generated IDs for nodes on the following axis, 
plus attributes they carry. -->
  +  <xsl:variable name="accumulated">
  +    <!-- Since call-template doesn't change context, iterate by position number. -->
  +    <xsl:call-template name="nextnode">
  +      <xsl:with-param name="this" select="1" />
  +      <xsl:with-param name="max" 
select="count(document(../a)//node()|following::node()|following::*/@*)" />
  +      <xsl:with-param name="idset" select="'+'" />
  +      <!-- Use + as delimiter to avoid spoofs from adjacent strings.
  +           Returned string from generate-id() can't contain +. -->
  +    </xsl:call-template>
  +  </xsl:variable>
  +  <!-- Summary data, so we have output when we pass. -->
  +  <xsl:text>Number of IDs accumulated: </xsl:text>
  +  <xsl:value-of 
select="count(document(../a)//node()|following::node()|following::*/@*)"/>
  +  <!-- Now, take one node of each kind, whose generated ID should not be in the 
accumulated string,
  +    surround generated ID by + to avoid substring matches, and see if it's in 
there. -->
  +  <!-- See if we duplicated an ID with the root -->
  +  <xsl:if test="contains($accumulated,concat('+',generate-id(/),'+'))">
  +    <xsl:text>FAIL on root node whose ID is </xsl:text>
  +    <xsl:value-of select="generate-id(/)"/>
  +  </xsl:if>
  +  <!-- See if we duplicated an ID with the element -->
  +  <xsl:if test="contains($accumulated,concat('+',generate-id(.),'+'))">
  +    <xsl:text>FAIL on side node whose ID is </xsl:text>
  +    <xsl:value-of select="generate-id(.)"/>
  +  </xsl:if>
  +  <!-- See if we duplicated an ID with the attribute -->
  +  <xsl:if test="contains($accumulated,concat('+',generate-id(./@att),'+'))">
  +    <xsl:text>FAIL on side/@att node whose ID is </xsl:text>
  +    <xsl:value-of select="generate-id(./@att)"/>
  +  </xsl:if>
  +  <!-- See if we duplicated an ID with the text node -->
  +  <xsl:if test="contains($accumulated,concat('+',generate-id(./text()),'+'))">
  +    <xsl:text>FAIL on side/text() node whose ID is </xsl:text>
  +    <xsl:value-of select="generate-id(./text())"/>
  +  </xsl:if>
  +  <!-- See if we duplicated an ID with the comment node -->
  +  <xsl:if test="contains($accumulated,concat('+',generate-id(./comment()),'+'))">
  +    <xsl:text>FAIL on side/comment() node whose ID is </xsl:text>
  +    <xsl:value-of select="generate-id(./comment())"/>
  +  </xsl:if>
  +  <!-- See if we duplicated an ID with the PI node -->
  +  <xsl:if 
test="contains($accumulated,concat('+',generate-id(./processing-instruction('s-pi')),'+'))">
  +    <xsl:text>FAIL on side/processing-instruction('s-pi') node whose ID is 
</xsl:text>
  +    <xsl:value-of select="generate-id(./processing-instruction('s-pi'))"/>
  +  </xsl:if>
  +  <!-- See if we duplicated an ID with a namespace node -->
  +  <xsl:if 
test="contains($accumulated,concat('+',generate-id(./namespace::*[1]),'+'))">
  +    <xsl:text>FAIL on side/namespace::*[1] node whose ID is </xsl:text>
  +    <xsl:value-of select="generate-id(./namespace::*[1])"/>
  +  </xsl:if>
  +  <!-- See if we duplicated an ID with an element from another document -->
  +  <xsl:if 
test="contains($accumulated,concat('+',generate-id(document('idkey49a.xml')//body),'+'))">
  +    <xsl:text>FAIL on 49a body node whose ID is </xsl:text>
  +    <xsl:value-of select="generate-id(document('idkey49a.xml')//body)"/>
  +  </xsl:if>
  +  <!-- See if we duplicated an ID with an attribute from another document -->
  +  <xsl:if 
test="contains($accumulated,concat('+',generate-id(document('idkey49a.xml')//body/@att),'+'))">
  +    <xsl:text>FAIL on 49a body node whose ID is </xsl:text>
  +    <xsl:value-of select="generate-id(document('idkey49a.xml')//body/@att)"/>
  +  </xsl:if>
  +  <!-- See if we duplicated an ID with a text node from another document -->
  +  <xsl:if 
test="contains($accumulated,concat('+',generate-id(document('idkey49a.xml')//body/text()),'+'))">
  +    <xsl:text>FAIL on 49a body node whose ID is </xsl:text>
  +    <xsl:value-of select="generate-id(document('idkey49a.xml')//body/text())"/>
  +  </xsl:if>
  +  <!-- See if we duplicated an ID with a comment node from another document -->
  +  <xsl:if 
test="contains($accumulated,concat('+',generate-id(document('idkey49a.xml')//comment()),'+'))">
  +    <xsl:text>FAIL on 49a body node whose ID is </xsl:text>
  +    <xsl:value-of select="generate-id(document('idkey49a.xml')//comment())"/>
  +  </xsl:if>
  +</xsl:template>
  +
  +<xsl:template name="nextnode">
  +  <xsl:param name="this"/>
  +  <xsl:param name="max"/>
  +  <xsl:param name="idset"/>
  +  <!-- Params this and max are index numbers, idset is the string we're 
accumulating. -->
  +  <xsl:variable name="this-id" 
select="generate-id((document(../a)//node()|following::node()|following::*/@*)[position()
 = $this])"/>
  +  <xsl:choose>
  +    <xsl:when test="$this &lt;= $max">
  +      <!-- Recurse, adding current ID to string of all IDs, with separators -->
  +      <xsl:call-template name="nextnode">
  +        <xsl:with-param name="this" select="$this+1" />
  +        <xsl:with-param name="max" select="$max" />
  +        <xsl:with-param name="idset" select="concat($idset,$this-id,'+')" />
  +      </xsl:call-template>
  +    </xsl:when>
  +    <xsl:otherwise>
  +      <!-- "return" the final idset -->
  +      <xsl:value-of select="$idset"/>
  +    </xsl:otherwise>
  +  </xsl:choose>
   </xsl:template>
   
   </xsl:stylesheet>
  
  
  
  1.2       +2 -2      xml-xalan/test/tests/conf/idkey/idkey49a.xml
  
  Index: idkey49a.xml
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/tests/conf/idkey/idkey49a.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- idkey49a.xml      1 Aug 2001 19:05:49 -0000       1.1
  +++ idkey49a.xml      2 Dec 2002 21:16:22 -0000       1.2
  @@ -1,4 +1,4 @@
  -<?xml version="1.0"?>
  +<?xml version="1.0" encoding="UTF-8"?>
   <doc>
  -  <body>49A-Hello</body>
  +  <body att="view">49A-Hello</body><!-- Comment in 49a -->
   </doc>
  
  
  
  1.2       +2 -2      xml-xalan/test/tests/conf/idkey/idkey49c.xml
  
  Index: idkey49c.xml
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/tests/conf/idkey/idkey49c.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- idkey49c.xml      1 Aug 2001 19:05:49 -0000       1.1
  +++ idkey49c.xml      2 Dec 2002 21:16:22 -0000       1.2
  @@ -1,4 +1,4 @@
  -<?xml version="1.0"?>
  +<?xml version="1.0" encoding="UTF-8"?>
   <outer>
  -  <body>49C-GoodBye</body>
  +  <body>49C-GoodBye</body><!-- Comment in 49c -->
   </outer>
  
  
  
  1.2       +1 -1      xml-xalan/test/tests/conf/idkey/idkey51.xml
  
  Index: idkey51.xml
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/tests/conf/idkey/idkey51.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- idkey51.xml       17 Dec 2001 14:27:34 -0000      1.1
  +++ idkey51.xml       2 Dec 2002 21:16:22 -0000       1.2
  @@ -1,4 +1,4 @@
   <?xml version="1.0" encoding="ISO-8859-1"?>
   <doc>
  -  <a>idkey49b.xml</a><!-- Shirt, Overt -->
  +  <a>idkey49a.xml</a>
   </doc>
  
  
  
  1.2       +2 -1      xml-xalan/test/tests/conf/idkey/idkey31.xml
  
  Index: idkey31.xml
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/tests/conf/idkey/idkey31.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- idkey31.xml       15 Dec 2000 19:34:34 -0000      1.1
  +++ idkey31.xml       2 Dec 2002 21:16:22 -0000       1.2
  @@ -2,7 +2,8 @@
   <docs>
     <doc xmlns:ext="http://somebody.elses.extension";>
       <section xmlns:foo="http://foo.com";>
  -      <inner xmlns:whiz="http://whiz.com/special/page"/>
  +      <inner xmlns:whiz="http://whiz.com/special/page"; att="view"><!-- Inner 
comment -->inner
  +text<?s-pi side ?></inner>
       </section>
     </doc>
   </docs>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to