RE: [xsl] Document Function Befuddlement

Subject: RE: [xsl] Document Function Befuddlement
From: "W Charlton" <XSLList@xxxxxxxxxx>
Date: Fri, 11 Jan 2008 09:38:12 -0000
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 Charlton
The yMonda team
yMonda Limited
w: www.ymonda.net


-----Original Message-----
From: Scott Trenda [mailto:Scott.Trenda@xxxxxxxx] 
Sent: 2008 January 10 18:53
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Document Function Befuddlement

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.


IE uses MSXML, which is generally solid and standard-compliant. libxslt
(xsltproc) is a good, free processor that is generally as dependable as
MSXML. I believe the latest version of Apple's Safari for Windows uses
libxslt; it's the only built-in libxslt implementation I know of in
Windows. (aside from XML IDEs, of course.)

~ Scott


-----Original Message-----
From: Signature House [mailto:systems@xxxxxxxxxxxxxxxxxx] 
Sent: Thursday, January 10, 2008 12:40 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Document Function Befuddlement

Scott

Thanks, that works, but it just makes the whole thing weirder.

I also tried:

<xsl:for-each
select="document($monthly_link/@link)/descendant-or-self::*">

but got the same results as before, only the first file came thru and it
added some blank lines:

Pos Name    Value
--- ----
1
2   daily
3   client
4   day     1
5
6   name    John
7

I'd really like to get rid of having to specify the /daily so I could
use it as a generic utility - just change the name of the file
with the list of file names and run this against it. Also, this wouldn't
work if the input files didn't all have the same structure.

I'll take Michael Kay's advice and try another processor.

Anyone have any suggestions for a 1.0 processor that'll run under
Windows XP (cheap or free)?

Thanks

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

-> -----Original Message-----
-> From: Scott Trenda [mailto:Scott.Trenda@xxxxxxxx]
-> Sent: Thursday, January 10, 2008 12:03 PM
-> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
-> Subject: RE: [xsl] Document Function Befuddlement
->
->
-> I'm... not too sure about the genuine fix for the problem, but this
-> might be an acceptable workaround:
->
-> <xsl:for-each
-> select="document($monthly_link/@link)/daily/descendant-or-self::*">
->
-> ~ Scott
->
->
-> -----Original Message-----
-> From: Signature House [mailto:systems@xxxxxxxxxxxxxxxxxx]
-> Sent: Thursday, January 10, 2008 10:57 AM
-> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
-> Subject: [xsl] Document Function Befuddlement
->
-> Document Function Befuddlement
->
-> I'm working on an application where I have to periodically run a
number
-> of xml files that I'm given through the same xsl transform.
-> Conveniently, I also get another xml file that lists the names of all
of
-> the data files, so this seemed like the perfect chance to
-> put the document function to good use (my first time).
->
-> I'm on a PC running XP SP2, using IE 7 & xsl 1.0. Below I've included
a
-> much reduced test process that I've been using to get it
-> working - it simply lists the position, name and value of all element
-> nodes.
->
-> 'day1.xml' & 'day2.xml' are the data files, 'monthly list.xml' is the
-> list of file names and I use 'list nodes.xml' to trigger the
-> whole thing by loading it into IE.
->
-> My befuddlement comes in because I'm getting more output from a more
-> restrictive selection criteria than I am from a less
-> restrictive selection criteria.
->
->
-> If, in 'monthly process.xsl', I use
->
-> <xsl:for-each select="document($monthly_link/@link)/daily//*">
->
-> I get, correctly:
->
-> Pos Name     Value
-> --- ----     -----
-> 1   client
-> 2   day      1
-> 3   name     John
-> 4   client
-> 5   day      2
-> 6   name     Margaret
->
->
-> However, this doesn't show the daily nodes, which I wanted included
-> also, so I tried:
->
-> <xsl:for-each select="document($monthly_link/@link)//*">
->
-> I get, unexpectedly:
->
-> Pos Name     Value
-> --- ----     -----
-> 1   daily
-> 2   client
-> 3   day      1
-> 4   name     John
->
->
-> What I expected (and wanted) from the use of //* is:
->
-> Pos Name     Value
-> --- ----     -----
-> 1   daily
-> 2   client
-> 3   day      1
-> 4   name     John
-> 5   daily
-> 6   client
-> 7   day      2
-> 8   name     Margaret
->
->
-> Would someone please explain why this is happening and what I should
do
-> to get the results I need?
->
-> Thanks in advance
->
-> Mike McBee
-> Signature House
->
->
->
->
-> monthly process.xsl
-> -------------------
-> <?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>Name</td><td>Value</td></tr>
->   <xsl:for-each select="SEE ABOVE">
->    <tr>
->     <td><xsl:number value="position()" format="1"/></td>
->     <td><xsl:value-of select="name(self::node())"/></td>
->     <td><xsl:value-of select="normalize-space(text())"/></td>
->    </tr>
->   </xsl:for-each>
->  </table>
-> </xsl:template>
-> </xsl:stylesheet>
->
->
-> list nodes.xml
-> --------------
-> <?xml version="1.0"?>
-> <?xml-stylesheet type="text/xsl" href="monthly process.xsl"?>
-> <null>null</null>
->
->
-> monthly list.xml
-> ----------------
-> <?xml version="1.0"?>
-> <monthly>
->  <day link="day1.xml"/>
->  <day link="day2.xml"/>
-> </monthly>
->
->
-> day1.xml
-> --------
-> <?xml version="1.0"?>
-> <daily>
->  <client>
->   <day>1</day>
->   <name>John</name>
->  </client>
-> </daily>
->
->
-> day2.xml
-> --------
-> <?xml version="1.0"?>
-> <daily>
->  <client>
->   <day>2</day>
->   <name>Margaret</name>
->  </client>
-> </daily>
->
->
->
->
->
->
->
->
->
->

Current Thread