This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problem with multiple xml docs and 1 xsl sheet


I can help you more specific if I can see the XML-files. But here a list of
possible problems:

1. The file DeptHours.xml has to be in the same directory like the
stylesheet. If this is not true, but the XML is in the same directory like
employee info XML, then you have to write "document('DeptHours.xml',.)".

2. There is a difference between root node '/' and root-element '/root'. I
can imagine that you forgot the root element. Furthermore you select many
roots from $hours. So I assume, your document doesn't look like

<Dept_Num>any id</Dept_Num>

If it looks like

<root>
    <Dept>
        <Dept_Num>1</Dept_Num>
        <Dept_Hours1>any</Dept_Hours1>
        <Dept_Hours2>any</Dept_Hours2>
        <Dept_Hours3>any</Dept_Hours3>
        <Dept_Hours4>any</Dept_Hours4>
    </Dept>
    <Dept>
        <Dept_Num>1</Dept_Num>
        <Dept_Hours1>any</Dept_Hours1>
        <Dept_Hours2>any</Dept_Hours2>
        <Dept_Hours3>any</Dept_Hours3>
        <Dept_Hours4>any</Dept_Hours4>
    </Dept>
</root>

you should write <xsl:variable name="hours"
select="document('DeptHours.xml')/*"/>

and then <xsl:for-each select="$hours/Dept[Dept_Num=$id]">

Regards,

Joerg

----- Original Message -----
From: "Gene LaCava" <e.f.lacava@verizon.net>
To: <xsl-list@lists.mulberrytech.com>
Sent: Wednesday, January 30, 2002 7:53 PM
Subject: [xsl] problem with multiple xml docs and 1 xsl sheet


> I am so stuck.....
>
> I am trying to print the hours info from an XML file DeptHours.xml and the
> emplyee information from another XML file.  Can anyone see what I'm doing
> wrong ?  The employee info comes out fine, but only the Dept_Hours heading
> and no detail info for the department hours.  The XSL file is below...
>
> Thank You in advance
>
> <?xml version="1.0" ?>
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>
> <xsl:output method="html" />
> <xsl:variable name="hours" select="document('DeptHours.xml')"/>
> <xsl:param name="id"/>
>
> <xsl:template match="dataroot">
> <HTML>
> <BODY>
> <TABLE BORDER="2">
> <TR>
> <TD>Department Hours</TD>
> </TR>
> <xsl:for-each select="$hours[Dept_Num=$id]">
> <TR>
> <TD><xsl:value-of select="Dept_Hours1"/></TD>
> <TD><xsl:value-of select="Dept_Hours2"/></TD>
> <TD><xsl:value-of select="Dept_Hours3"/></TD>
> <TD><xsl:value-of select="Dept_Hours4"/></TD>
> </TR>
> </xsl:for-each>
> </TABLE>
>
> <TABLE BORDER="2">
> <TR>
> <TD>Department Number</TD>
> <TD>Department Name</TD>
> <TD>Department Phone</TD>
> </TR>
> <xsl:for-each select="DeptEmployees[Dept_Num=$id]">
> <TR>
> <TD><xsl:value-of select="Dept_Num"/></TD>
> <TD><xsl:value-of select="Dept_Name"/></TD>
> <TD><xsl:value-of select="Dept_Phone"/></TD>
> <TD><xsl:value-of select="Employee_First_Name"/></TD>
> <TD><xsl:value-of select="Employee_Last_Name"/></TD>
> <TD><xsl:value-of select="Employee_Title"/></TD>
> </TR>
> </xsl:for-each>
> </TABLE>
> </BODY>
> </HTML>
> </xsl:template>
> </xsl:stylesheet>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]