Jump to content

New to this


BigAl75

Recommended Posts

OK, sorry if this has been asked before, but I did a search, and must not be searching for the correct term.Here is a part of the information from the xml file:

<EmployeeList>    <Employee>        <EmployeeName>Max</EmployeeName>        <DOB>Apr 7, 1967</DOB>        <SSN>123-98-4567</SSN>        <HPhone>123-3232</HPhone>        <HAddress>            <Apt>Apt 8</Apt>            <Street>1239 W 99 ST</Street>            <City>Los Angeles</City>            <State>CA</State>            <Zip>90007</Zip>        </HAddress>                <CPhone>123-9876</CPhone>        <CPhone>123-9876</CPhone>        <Appointment>            <Affiliations>                <Dept>CS Dept</Dept>                <Title>Assistant Professor</Title>                <Type>Faculty</Type>            </Affiliations>            <OPhone>123-9982</OPhone>            <OAddress>CS-102</OAddress>            <OHrs>1:00-3:00Pm</OHrs>        </Appointment>         <Appointment>            <Affiliations>                <Dept>IMSC</Dept>                <Title>Assistant Professor</Title>                <Type>Faculty</Type>            </Affiliations>            <OPhone>232-2323</OPhone>            <OAddress>PH-998</OAddress>            <OHrs>3:00-4:00Pm</OHrs>        </Appointment>        <Appointment>            <Affiliations>                <Dept>ISI</Dept>                <Title>Assistant Professor</Title>                <Type>Faculty</Type>            </Affiliations>            <OPhone>232-5454</OPhone>            <OAddress>IS-834</OAddress>            <OHrs>4:00-5:00Pm</OHrs>        </Appointment>    </Employee>    <Employee>        <EmployeeName>Len</EmployeeName>        <DOB>Mar 7, 1978</DOB>        <SSN>123-67-4567</SSN>        <HPhone>444-2323</HPhone>        <HAddress>            <Apt>Apt 6</Apt>            <Street>4321 E 28 ST</Street>            <City>Los Angeles</City>            <State>CA</State>            <Zip>90008</Zip>        </HAddress>                <CPhone>434-8763</CPhone>        <Appointment>            <Affiliations>                <Dept>IMSC</Dept>                <Title>Assistant</Title>                <Type>Student</Type>            </Affiliations>            <OPhone>121-9875</OPhone>            <OAddress>PH-123</OAddress>        </Appointment>     </Employee></EmployeeList>

Here is part of my xsl code:

<table style="width: 100%; border: 1px solid Black; background-color: green;" cellpadding="2" cellspacing="0">              <tr style="text-align: center; font-weight: bold; font-family: Verdana; font-size: 12px;">                <td style="border: 1px solid Black; vertical-align: top; color: white;">Name</td>                <td style="border: 1px solid Black; vertical-align: top; color: white;">D.O.B.</td>                <td style="border: 1px solid Black; vertical-align: top; color: white;">SSN</td>                <td style="border: 1px solid Black; vertical-align: top; color: white;">H. Phone</td>                <td style="border: 1px solid Black; vertical-align: top; color: white;">H. Address</td>                <td style="border: 1px solid Black; vertical-align: top; color: white;">C. Phone</td>                <td style="border: 1px solid Black; vertical-align: top; color: white;">Affiliations</td>                <td style="border: 1px solid Black; vertical-align: top; color: white;">O. Phone</td>                <td style="border: 1px solid Black; vertical-align: top; color: white;">O. Address</td>                <td style="border: 1px solid Black; vertical-align: top; color: white;">O. Hours</td>              </tr>              <xsl:for-each select="EmployeeList/Employee">               <tr style="font-family: Verdana; font-size: 11px;">           <td style="border: 1px solid Black; background-color: gray; width: 10%; vertical-align: top;"><xsl:value-of select="EmployeeName"/></td>                    <td style="border: 1px solid Black; background-color: silver; width: 10%; vertical-align: top;"><xsl:value-of select="DOB"/></td>                    <td style="border: 1px solid Black; background-color: gray; width: 10%; vertical-align: top;"><xsl:value-of select="SSN"/></td>                    <td style="border: 1px solid Black; background-color: silver; width: 10%; vertical-align: top;"><xsl:value-of select="HPhone"/></td>                    <td style="border: 1px solid Black; background-color: gray; width: 10%; vertical-align: top;"><xsl:value-of select="HAddress"/></td>                    <td style="border: 1px solid Black; background-color: silver; width: 10%; vertical-align: top;"><xsl:value-of select="CPhone"/></td>                    <td style="border: 1px solid Black; background-color: gray; width: 10%; vertical-align: top;"><xsl:value-of select="Appointment/Affiliations"/></td>                    <td style="border: 1px solid Black; background-color: silver; width: 10%; vertical-align: top;"><xsl:value-of select="Appointment/OPhone"/></td>                    <td style="border: 1px solid Black; background-color: gray; width: 10%; vertical-align: top;"><xsl:value-of select="Appointment/OAddress"/></td>                    <td style="border: 1px solid Black; background-color: silver; width: 10%; vertical-align: top;"><xsl:value-of select="Appointment/OHours"/></td>              </tr>              </xsl:for-each>            </table>

How do I get both of the cell number to show up, along with all the information inside the <Appointment> tags? Also, how do I get it NOT to show the <Type>?Here it is on the web:http://www.ny-outdoors.com/for_school/employee.xmlThanks for the help.Al

Link to comment
Share on other sites

What do you mean by "both of the cell number to show up"?As for how to hide the type. I think the cleanest (though structually looked, not the best) method, might be the <b> markup method, with adjusting the CSS to use "display: none" of course.

Link to comment
Share on other sites

I got another solution for you, but it's also a bit messy. It relyes on the position of the code. The last child of Afflications won't be displayed whatever it is. It doesn't spesifically target the Type node, which is the problem. Anyway... I also made some other modifications to the code if you don't mind. Such include:1. Moving the repeated CSS style attributes into classes at the head section.2. Making every appointment show instead of only the first one.3. There was a misspelling in your stylesheet for selecting the OHours. Fixed now.Here's the code:

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">    <xsl:template match="/">    <html>  <head>  	<style type="text/css">  	td.header {border: 1px solid Black; vertical-align: top; color: white;}  	td.data {border: 1px solid Black; background-color: gray; width: 10%; vertical-align: top;}  	</style>  </head>        <body>            <table style="width: 100%; border: 1px solid Black; background-color: green;" cellpadding="2" cellspacing="0">            	<tr style="text-align: center; font-weight: bold; font-family: Verdana; font-size: 12px;">    	<td class="header">Name</td>    	<td class="header">D.O.B.</td>    	<td class="header">SSN</td>    	<td class="header">H. Phone</td>    	<td class="header">H. Address</td>    	<td class="header">C. Phone</td>    	<td class="header">Affiliations</td>    	<td class="header">O. Phone</td>    	<td class="header">O. Address</td>    	<td class="header">O. Hours</td>              	</tr>  	<xsl:for-each select="EmployeeList/Employee">      <tr style="font-family: Verdana; font-size: 11px;">           <td class="data"><xsl:value-of select="EmployeeName"/></td>                    <td class="data"><xsl:value-of select="DOB"/></td>    	<td class="data"><xsl:value-of select="SSN"/></td>                    <td class="data"><xsl:value-of select="HPhone"/></td>                    <td class="data"><xsl:value-of select="HAddress"/></td>                    <td class="data"><xsl:value-of select="CPhone"/></td>    	<td class="data">    	<ol>    	<xsl:for-each select="Appointment/Affiliations">      <li>      <xsl:for-each select="*">      <xsl:if test="position()!=last()">      <xsl:value-of select="." /><br />      </xsl:if>      </xsl:for-each>      </li>    	</xsl:for-each>    	</ol>    	</td>    	<td class="data">    	<ol>    	<xsl:for-each select="Appointment/OPhone">      <li><xsl:value-of select="current()" /></li>    	</xsl:for-each>    	</ol>    	</td>    	<td class="data">    	<ol>    	<xsl:for-each select="Appointment/OAddress">      <li><xsl:value-of select="current()" /></li>    	</xsl:for-each>    	</ol>    	</td>    	<td class="data">    	<ol>    	<xsl:for-each select="Appointment/OHrs">      <li><xsl:value-of select="current()" /></li>    	</xsl:for-each>    	</ol>    	</td>    </tr>  	</xsl:for-each>            </table>        </body>    </html>    </xsl:template></xsl:stylesheet>

Link to comment
Share on other sites

This is what I meant by "both cell numbers to show up":

</HAddress>              <CPhone>123-9876</CPhone>       <CPhone>123-9876</CPhone><Appointment>

Not a typo, this is exactly as it came when we got the assignment.Thanks for the help.Al

Link to comment
Share on other sites

Similarly to the code above, replace

                   <td class="data"><xsl:value-of select="CPhone"/></td>

With

    <td class="data">    <ul>    <xsl:for-each select="CPhone">     <li><xsl:value-of select="current()" /></li>    </xsl:for-each>    </ul>    </td>

It should show the desired output.

Link to comment
Share on other sites

Is there a way to do that without creating a list?

Of course there is. You are completely free to adjust the XHTML inside. It won't give any other results:
   <td class="data">   <xsl:for-each select="CPhone">     <xsl:value-of select="current()" /><br />   </xsl:for-each>   </td>

Link to comment
Share on other sites

Conditional statements maybe?

<xsl:if test="EmployeeName=Joe">

If you would like to have more than one employee selected, there are several ways to do this. I would personally go to grouping the table row in another template and use the "apply-templates" element to apply it for every desired employee.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...