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

Re: Can't get predicates working.

Subject: Re: Can't get predicates working.
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Sat, 7 May 2005 20:51:16 -0700 (PDT)
xsl template match
Hi Marco,
  Please try this XSL.. (I am assuming, you wish to
generate HTML)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"

<xsl:output method="html" indent="yes" />
<xsl:template match="/company">
         <xsl:apply-templates select="division" />
<xsl:template match="division">
    <table border="1">
          Division Name = <xsl:value-of select="@DID"
      <xsl:for-each select="projects/project">
          <td>PID=<xsl:value-of select="@PID" /></td>
          <td>PNAME=<xsl:value-of select="PNAME"
          <td>BUDGET=<xsl:value-of select="BUDGET"
        <xsl:for-each select="assigns/assign">
	    <td>EID=<xsl:value-of select="@refEID" /></td>
= current()/@refEID]/ENAME" /></td>
= current()/@refEID]/OFFICE" /></td>
	    <td>HOURS=<xsl:value-of select="HOURS" /></td>

My solution differs from Aron's in writing style. Aron
has used xsl:apply-templates (which is sometimes
called push processing).

While I have used xsl:for-each (which is sometimes
called pull processing) ..

We may even mix these two styles of programming
depending on requirement..


--- Marco Mastrocinque <mmfive@xxxxxxxxxxxxxxx> wrote:
> Hi All,
>       I'm having trouble with a predicate selection
> (i.e. a conditional
> selection). For the following xml structure.
> <company>
>      <division DID="XXX">
>      <projects>
>          <project PID='XYZ'> (Project ID)
>              <PNAME>Some Name</PNAME> (Project Name)
>              <BUDGET>111</BUDGET>
>              <assigns>
>                  <assign refEID='XXX000'>   
>                    <HOURS>12</HOURS>
>                  </assign>
>                  <assign refEID='XXX001'> 
>                    <HOURS>78</HOURS>
>                  </assign>
>              <assigns>
>           </project>
>           <project PID='XY1'>
>              <PNAME>Some OtherName</PNAME>
>              <BUDGET>112</BUDGET>
>              <assigns>
>                  <assign refEID='XXX000'>   
>                    <HOURS>34</HOURS>
>                  </assign>
>                  <assign refEID='XXX002'> 
>                    <HOURS>1234</HOURS>
>                  </assign>
>              <assigns>
>           </project>
>           Etc..
>       </projects>
>       <employees>
> 	    <employee EID='XXX000'>
>             <ENAME>Joe Blow</ENAME>
>             <OFFICE>1204</OFFICE>
>             <BIRTHDATE>1924-08-01</BIRTHDATE>
>           </employee>
>           <employee EID='XXX001'>
>             <ENAME>Joe Smith</ENAME>
>             <OFFICE>1203</OFFICE>
>             <BIRTHDATE>1930-08-01</BIRTHDATE>
>           </employee>
>           <employee EID='XXX002'>
>             <ENAME>Joe Jerry</ENAME>
>             <OFFICE>0003</OFFICE>
>             <BIRTHDATE>1930-08-01</BIRTHDATE>
>           </employee>              	
>       </employees>   
>       </division>
> Etc.. (there are multiple divisions with the same
> structure, employees can
> only work for one division and a project only
> belongs to a single division
> )  
> </company>
> I won't to have a table that shows PID, PNAME,
> BUDGET and then the employee
> EID (unique identifier), the employee name (ENAME),
> OFFICE and HOURS spent
> on each project.
> The output I won't is 
> Division Name = XXX
> PID='XYZ'   PNAME=Some Name BUDGET=111      
> EID= XXX000 ENAME= Joe Blow  OFFICE=1204 HOURS=12
> EID= XXX001 ENAME= Joe Smith OFFICE=1203 HOURS=78
> PID=' XY1'  PNAME= Some OtherName BUDGET=112
> EID= XXX000 ENAME= Joe Blow  OFFICE=1204 HOURS=34
> EID= XXX002 ENAME= Joe Jerry OFFICE=0003 HOURS=1234
> This above output is done for every division.
> I have to match the refEID attribute of assign
> element with the EID
> attribute of employee element. Then out the EID
> (refEID), with the ENAME and
> OFFICE elements, while looping the projects for each
> division. I know it is
> a conditional selection (I think?), but I just can't
> get working.
> Thanks Marco Mastrocinque

Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!

Current Thread


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.
First Name
Last Name
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.