[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] trouble looping using xsl:for-each and xsl:if
I have gone round and round on this problem and seem to be getting nowhere. What do I have to change in my xsl file to get the desired output. I know I am close, but cannot see the forest for the trees. It seems like my xsl:if statements are being ignored after the first one executes. I do not understand why the first cell in correct and the last cell is correct but all the in-between cells are in error. Any help is greatly appreciated. Input xml file:+++++++++++++++++++++++++++++++++ <ematrix> <businessObject> <objectName>2009-12</objectName> <fromRelationshipList> <relationship> <relationshipDefRef>Subordinate Submittal</relationshipDefRef> <attributeList> <attribute> <name>Due Customer</name> <datetime>2009-12-21T05:00:00Z</datetime> </attribute> <attribute> <name>Promise Date</name> <datetime>2009-12-19T05:00:00Z</datetime> </attribute> <attribute> <name>Submitted Date</name> <datetime>2009-12-20T05:00:00Z</datetime> </attribute> <attribute> <name>Responsible IPT</name> <string>BMC4I</string> </attribute> </attributeList> </relationship> <relationship> <relationshipDefRef>Subordinate Submittal</relationshipDefRef> <attributeList> <attribute> <name>Due Customer</name> <datetime>2009-12-15T05:00:00Z</datetime> </attribute> <attribute> <name>Promise Date</name> <datetime>2009-12-14T05:00:00Z</datetime> </attribute> <attribute> <name>Submitted Date</name> <datetime></datetime> </attribute> <attribute> <name>Responsible IPT</name> <string>LAUNCHER</string> </attribute> </attributeList> </relationship> </fromRelationshipList> </businessObject> <businessObject> <objectName>2010-01</objectName> <fromRelationshipList> <relationship> <relationshipDefRef>Subordinate Submittal</relationshipDefRef> <attributeList> <attribute> <name>Due Customer</name> <datetime>2010-01-20T05:00:00Z</datetime> </attribute> <attribute> <name>Promise Date</name> <datetime>2010-01-19T05:00:00Z</datetime> </attribute> <attribute> <name>Submitted Date</name> <datetime>2010-01-18T05:00:00Z</datetime> </attribute> <attribute> <name>Responsible IPT</name> <string>BMC4I</string> </attribute> </attributeList> </relationship> <relationship> <relationshipDefRef>Subordinate Submittal</relationshipDefRef> <attributeList> <attribute> <name>Due Customer</name> <datetime>2010-01-20T05:00:00Z</datetime> </attribute> <attribute> <name>Promise Date</name> <datetime>2010-01-20T05:00:00Z</datetime> </attribute> <attribute> <name>Submitted Date</name> <datetime>2010-01-20T05:00:00Z</datetime> </attribute> <attribute> <name>Responsible IPT</name> <string>CMR</string> </attribute> </attributeList> </relationship> <relationship> <relationshipDefRef>Subordinate Submittal</relationshipDefRef> <attributeList> <attribute> <name>Due Customer</name> <datetime>2010-01-10T05:00:00Z</datetime> </attribute> <attribute> <name>Promise Date</name> <datetime>2010-01-10T05:00:00Z</datetime> </attribute> <attribute> <name>Submitted Date</name> <datetime>2010-01-10T05:00:00Z</datetime> </attribute> <attribute> <name>Responsible IPT</name> <string>LAUNCHER</string> </attribute> </attributeList> </relationship> </fromRelationshipList> </businessObject> <businessObject> <objectName>2010-02</objectName> <fromRelationshipList> <relationship> <relationshipDefRef>Subordinate Submittal</relationshipDefRef> <attributeList> <attribute> <name>Due Customer</name> <datetime>2010-01-11T05:00:00Z</datetime> </attribute> <attribute> <name>Promise Date</name> <datetime>2010-01-12T05:00:00Z</datetime> </attribute> <attribute> <name>Submitted Date</name> <datetime>2010-01-13T05:00:00Z</datetime> </attribute> <attribute> <name>Responsible IPT</name> <string>LAUNCHER</string> </attribute> </attributeList> </relationship> </fromRelationshipList> </businessObject> </ematrix> +++++++++++++++++++++++++++++++++ my xslt:+++++++++++++++++++++++++++++++++ <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="iso-8859-1"/> <xsl:template match="ematrix"> <html> <body> <table border='1'> <tr> <th>Name</th> <th>B</th> <th>C</th> <th>L</th> </tr> <xsl:for-each select="businessObject"> <xsl:sort select="objectName"/> <tr> <td nowrap='nowrap'><xsl:value-of select="objectName"/></td> <td> <xsl:if test="fromRelationshipList/relationship/relationshipDefRef[text()='Subor dinate Submittal'] and fromRelationshipList/relationship/attributeList/attribute[name='Responsi ble IPT']/string = 'BMC4I'"> <p><xsl:value-of select="substring(fromRelationshipList/relationship/attributeList/attrib ute[name='Due Customer']/datetime,1,10)"/></p> <p><xsl:value-of select="substring(fromRelationshipList/relationship/attributeList/attrib ute[name='Promise Date']/datetime,1,10)"/></p> <p><xsl:value-of select="substring(fromRelationshipList/relationship/attributeList/attrib ute[name='Submitted Date']/datetime,1,10)"/></p> </xsl:if> </td> <td> <xsl:if test="fromRelationshipList/relationship/relationshipDefRef[text()='Subor dinate Submittal'] and fromRelationshipList/relationship/attributeList/attribute[name='Responsi ble IPT']/string = 'CMR'"> <p><xsl:value-of select="substring(fromRelationshipList/relationship/attributeList/attrib ute[name='Due Customer']/datetime,1,10)"/></p> <p><xsl:value-of select="substring(fromRelationshipList/relationship/attributeList/attrib ute[name='Promise Date']/datetime,1,10)"/></p> <p><xsl:value-of select="substring(fromRelationshipList/relationship/attributeList/attrib ute[name='Submitted Date']/datetime,1,10)"/></p> </xsl:if> </td> <td> <xsl:if test="fromRelationshipList/relationship/relationshipDefRef[text()='Subor dinate Submittal'] and fromRelationshipList/relationship/attributeList/attribute[name='Responsi ble IPT']/string = 'LAUNCHER'"> <p><xsl:value-of select="substring(fromRelationshipList/relationship/attributeList/attrib ute[name='Due Customer']/datetime,1,10)"/></p> <p><xsl:value-of select="substring(fromRelationshipList/relationship/attributeList/attrib ute[name='Promise Date']/datetime,1,10)"/></p> <p><xsl:value-of select="substring(fromRelationshipList/relationship/attributeList/attrib ute[name='Submitted Date']/datetime,1,10)"/></p> </xsl:if> </td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> +++++++++++++++++++++++++++++++++ my actual output.htm+++++++++++++++++++++++++++++++++ <html> <body> <table border="1"> <tr> <th>Name</th> <th>B</th> <th>C</th> <th>L</th> </tr> <tr> <td nowrap>2009-12</td> <td> <p>2009-12-21</p> <p>2009-12-19</p> <p>2009-12-20</p> </td> <td></td> <td> <p>2009-12-21</p> <p>2009-12-19</p> <p>2009-12-20</p> </td> </tr> <tr> <td nowrap>2010-01</td> <td> <p>2010-01-20</p> <p>2010-01-19</p> <p>2010-01-18</p> </td> <td> <p>2010-01-20</p> <p>2010-01-19</p> <p>2010-01-18</p> </td> <td> <p>2010-01-20</p> <p>2010-01-19</p> <p>2010-01-18</p> </td> </tr> <tr> <td nowrap>2010-02</td> <td></td> <td></td> <td> <p>2010-01-11</p> <p>2010-01-12</p> <p>2010-01-13</p> </td> </tr> </table> </body> </html> +++++++++++++++++++++++++++++++++ Desired output.htm+++++++++++++++++++++++++++++++++ <html> <body> <table border="1"> <tr> <th>Name</th> <th>B</th> <th>C</th> <th>L</th> </tr> <tr> <td nowrap>2009-12</td> <td> <p>2009-12-21</p> <p>2009-12-19</p> <p>2009-12-20</p> </td> <td></td> <td> <p>2009-12-15</p> <p>2009-12-14</p> <p></p> </td> </tr> <tr> <td nowrap>2010-01</td> <td> <p>2010-01-20</p> <p>2010-01-19</p> <p>2010-01-18</p> </td> <td> <p>2010-01-20</p> <p>2010-01-20</p> <p>2010-01-20</p> </td> <td> <p>2010-01-10</p> <p>2010-01-10</p> <p>2010-01-10</p> </td> </tr> <tr> <td nowrap>2010-02</td> <td></td> <td></td> <td> <p>2010-01-11</p> <p>2010-01-12</p> <p>2010-01-13</p> </td> </tr> </table> </body> </html> +++++++++++++++++++++++++++++++++ Mark Miller MEADS International, Inc. Orlando, Fl USA Mark J. Miller Orlando, FL
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|