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

Document Function Befuddlement - results

Subject: Document Function Befuddlement - results
From: "Signature House" <systems@xxxxxxxxxxxxxxxxxx>
Date: Tue, 22 Jan 2008 13:45:43 -0500
  Document Function Befuddlement - results
Document Function Befuddlement - results

As you may remember, I was getting unexpected results when I tried running a transform against multiple XML input files (unexpected
in that I wasn't getting the same results that I got when I ran the transform against the XML files individually).

I was using statements in this form in IE7:

<xsl:template match="/">
  <xsl:variable name="file_list" select="document('file name list.xml.xml')/monthly/day"/>
  <xsl:for-each select="document($file_list/@link)//*">

and other variations, resulting in either absent or extra lines appearing in the result.

Michael Kay remarked that it looked like a bug in the IE7 processor and suggested that I try another processor. I did, and the above
coding worked fine - IE was the problem.

After experimenting (a lot), I found that this worked correctly in IE7:

 <xsl:variable name="file_list" select="document('file name list.xml')//@link"/>
  <xsl:for-each select="document($file_list)">
   <xsl:for-each select="//*|//@*">


My thanks for your help, this list is a great resource.

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


Element and Attribute List, by File
Position  Level  Path            Name    Value     Type
--------  -----  --------------  ------  --------  ---------
1         1      /               daily             element
2         2      /daily/         client            element
3         2      /daily/client/  s       m         attribute
4         3      /daily/client/  day     1         element
5         3      /daily/client/  name    John      element
1         1      /               daily             element
2         2      /daily/         client            element
3         2      /daily/client/  s       f         attribute
4         3      /daily/client/  day     2         element
5         3      /daily/client/  name    Margaret  element



listnodes.xsl
-------------
<?xml version="1.0"?>
<xsl:template match="/">
 <xsl:variable name="file_list" select="document('file name list.xml')//@link"/>
 <table border="1">
  <tr><td colspan="6">Element and Attribute List, by File</td></tr>
  <tr><td>Position</td><td>Level</td><td>Path</td>
  <td>Name</td><td>Value</td><td>Type</td></tr>
  <xsl:for-each select="document($file_list)">
   <xsl:for-each select="//*|//@*">
    <xsl:if test="''=''">
     <tr>
      <!-- Get the sequential position in the node set -->
      <td><xsl:number value="position()"/></td>
      <!-- Get the level in the tree -->
      <td><xsl:value-of select="count(ancestor-or-self::*)"/></td>
      <!-- Get the path -->
      <td>
       <xsl:for-each select="ancestor::node()">
        <xsl:value-of select="name()"/>
        <xsl:text>/</xsl:text>
       </xsl:for-each>
      </td>
      <!-- Get the node name -->
      <td><xsl:value-of select="name(self::node())"/></td>
      <xsl:choose>
       <xsl:when test="self::*">
        <!-- For an element node, get the value and indicate type -->
        <td><xsl:value-of select="normalize-space(text())"/></td>
        <td><xsl:value-of select="'element'"/></td>
       </xsl:when>
       <xsl:otherwise>
        <xsl:choose>
         <xsl:when test="count(.|../@*)=count(../@*)">
          <!-- For an attribute, get the value and indicate type -->
          <td><xsl:value-of select="normalize-space(.)"/></td>
          <td><xsl:value-of select="'attribute'"/></td>
         </xsl:when>
         <xsl:otherwise>
          <!-- For anything else -->
          <td><xsl:value-of select="normalize-space(.)"/></td>
          <td><xsl:value-of select="'other'"/></td>
         </xsl:otherwise>
        </xsl:choose>
       </xsl:otherwise>
      </xsl:choose>
     </tr>
    </xsl:if>
   </xsl:for-each>
  </xsl:for-each>
 </table>
</xsl:template>
</xsl:stylesheet>

launch list nodes.xml
---------------------
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href=".//list nodes.xsl"?>
<null>null</null>

file name list.xml
------------------
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl"?>
<monthly>
  <day link="day1.xml"/>
  <day link="day2.xml"/>
</monthly>

day1.xml
--------
<?xml version="1.0"?>
<daily>
  <client s="m">
    <day>1</day>
    <name>John</name>
  </client>
</daily>

day2.xml
--------
<?xml version="1.0"?>
<daily>
  <client s="f">
    <day>2</day>
    <name>Margaret</name>
  </client>
</daily>

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-2013 All Rights Reserved.