RE: [xsl] Document Function Befuddlement

Subject: RE: [xsl] Document Function Befuddlement
From: "Signature House" <systems@xxxxxxxxxxxxxxxxxx>
Date: Fri, 11 Jan 2008 12:59:49 -0500
William Charlton wrote:
-> Assuming you are using JavaScript to process the transform, could you show
-> your JavaScript or a link to the page you are testing on?
->
-> It is possible that there is a problem there.
->

William,

I included everything I'm using in the original post - no Javascipt, I simply open the 'list nodes.xml' in IE and everything runs
from that. And I'm doing it all local, so no link.

*****************************************************************

Scott Trenda wrote:
-> Well, the second one makes sense; descendant-or-self::* also selects
-> root nodes, and each new document has a root node. Also, your stylesheet
-> would probably be more easily debugged by using these in the <for-each>:
->
-> <td><xsl:number/></td>
-> <td><xsl:value-of select="name()"/></td>
-> <td><xsl:value-of select="normalize-space()"/></td>
->
-> That'll give you the position in the source document (instead of the
-> position in the context node-set), the name of the context node,
-> whatever it may be (avoid any self:: restriction confusion here), and
-> the native string-value of the node. Perhaps then it'll be clear as to
-> what exactly the processor is computing.
->
->

Scott,

I added the 3 statements you provided (in parallel with what was already there) and added in a bit more of the original template
that I took the sample from to get more info (level & path to the node) and re-ran it with both variations
['/daily/descendant-or-self::node()' and 'descendant-or-self::node()'].

I've included the new code below and the results. Strangely, the number element produced all 1's. And the
'descendant-or-self::node()' version contains an contains an additional first line that isn't present in the
'/daily/descendant-or-self::node()' variation.


I'm still working on Michael Kay's suggestion to try another processor.

Mike McBee
Signature House
systems@xxxxxxxxxxxxxxxxxx
www.signaturehouse.net
304-842-3386


monthly process.xml
-------------------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
 <table border="1">
  <xsl:variable name="monthly_link" select="document('monthly list.xml')/monthly/day"/>
  <tr><td>Pos</td><td>Level</td><td>Path</td><td>Name</td><td>Value</td></tr>

  <xsl:for-each select="document($monthly_link/@link)SEE BELOW">

   <tr>
    <td>{<xsl:number value="position()"/>}-{<xsl:number/>}</td>
    <td><xsl:value-of select="count(ancestor-or-self::*)"/></td>
    <td>
     <xsl:for-each select="ancestor::node()">
      <xsl:value-of select="name()"/>
      <xsl:text>/</xsl:text>
     </xsl:for-each>
    </td>
    <td>{<xsl:value-of select="name(self::node())"/>}-{<xsl:value-of select="name()"/>}</td>
    <td>{<xsl:value-of select="normalize-space(text())"/>}-{<xsl:value-of select="normalize-space()"/>}</td>
   </tr>

  </xsl:for-each>

 </table>
</xsl:template>
</xsl:stylesheet>


/daily/descendant-or-self::node() variation:

Pos      Level Path                Name              Value
---      ----- ------------------- ----------------- -----
{1}-{1}  1     /                   {daily}-{daily}   {}-{1 John}
{2}-{1}  2     /daily/             {client}-{client} {}-{1 John}
{3}-{1}  3     /daily/client/      {day}-{day}       {1}-{1}
{4}-{1}  3     /daily/client/day/  {}-{}             {}-{1}
{5}-{1}  3     /daily/client/      {name}-{name}     {John}-{John}
{6}-{1}  3     /daily/client/name/ {}-{}             {}-{John}
{7}-{1}  1     /X{daily}-{daily}                     {}-{2 Margaret}
{8}-{1}  2     /daily/             {client}-{client} {}-{2 Margaret}
{9}-{1}  3     /daily/client/      {day}-{day}       {2}-{2}
{10}-{1} 3     /daily/client/day/  {}-{}             {}-{2}
{11}-{1} 3     /daily/client/      {name}-{name}     {Margaret}-{Margaret}
{12}-{1} 3     /daily/client/name/ {}-{}             {}-{Margaret}


descendant-or-self::node() variation:

Pos      Level Path                Name              Value
---      ----- ------------------- ----------------- -----
{1}-{1}  0                         {}-{}             {}-{1 John}
{2}-{1}  1     /                   {daily}-{daily}   {}-{1 John}
{3}-{1}  2     /daily/             {client}-{client} {}-{1 John}
{4}-{1}  3     /daily/client/      {day}-{day}       {1}-{1}
{5}-{1}  3     /daily/client/day/  {}-{}             {}-{1}
{6}-{1}  3     /daily/client/      {name}-{name}     {John}-{John}
{7}-{1}  3     /daily/client/name/ {}-{}             {}-{John}

Current Thread