Subject: [xsl] for-each: is there a better way to do this? From: Amy Kaizerman <amy.j.kaizerman@xxxxxxxx> Date: Mon, 29 Oct 2001 15:45:27 -0800 |
Hi! I'm still trying to figure things out and wanted to ask if there was a better way to build my stylesheet. I'm using for-each a lot and it seems like I should be using apply-templates more, but I'm just not sure how to do that. I would greatly appreciate any help given. Here's my XML: <?xml version="1.0"?> <Aps:VpmResultSet xmlns:Aps="http://www.assist.com/" xmlns:ino="http://namespaces.softwareag.com/tamino/response2"> <Aps:PartStructure> <Aps:Name>tmp</Aps:Name> <Aps:Description>tmp for SC</Aps:Description> <Aps:RevisionLevel>A</Aps:RevisionLevel> <Aps:PartNumber>8574</Aps:PartNumber> <Aps:TopAssemblyName>SC</Aps:TopAssemblyName> <Aps:AlternateTopAssemblyName>SC</Aps:AlternateTopAssemblyName> <Aps:PartRelationship> <Aps:PreviousAssembly> <Aps:Name>a thing</Aps:Name> <Aps:PartNumber>8574</Aps:PartNumber> <Aps:QuantityPreviousAssembly> <Aps:NumberOfUnits>1</Aps:NumberOfUnits> <Aps:UnitOfMeasure>EA</Aps:UnitOfMeasure> </Aps:QuantityPreviousAssembly> </Aps:PreviousAssembly> </Aps:PartRelationship> <Aps:AsDesigned> <Aps:Drawing> <Aps:Type>Assembly</Aps:Type> <Aps:Name>another thing</Aps:Name> <Aps:Author>CM</Aps:Author> <Aps:DocumentId>857</Aps:DocumentId> <Aps:DocumentType>formtek viewer</Aps:DocumentType> <Aps:RevisionLevel>A</Aps:RevisionLevel> <Aps:Sheets id="178717"> <Aps:Number>1</Aps:Number> <Aps:DateTime time="999886589338" search="20010403">04 03 2001 23:12:26 PDT </Aps:DateTime> <Aps:Comments>Data</Aps:Comments> <Aps:LocatorUrl>http://yahoo.com</Aps:LocatorUrl> <Aps:Accessor>edstar</Aps:Accessor> </Aps:Sheets> <Aps:Sheets id="12163643"> <Aps:Number>2</Aps:Number> <Aps:DateTime time="999886589338" search="20010403">04 03 2001 23:12:26 PDT </Aps:DateTime> <Aps:Comments>Data</Aps:Comments> <Aps:LocatorUrl>http://yahoo.com</Aps:LocatorUrl> <Aps:Accessor>edstar</Aps:Accessor> </Aps:Sheets> </Aps:Drawing> <Aps:Drawing> <Aps:Type>Assembly</Aps:Type> <Aps:Name>another thing 2</Aps:Name> <Aps:Author>CM</Aps:Author> <Aps:DocumentId>857</Aps:DocumentId> <Aps:DocumentType>formtek viewer</Aps:DocumentType> <Aps:RevisionLevel>A</Aps:RevisionLevel> <Aps:Sheets id="178717"> <Aps:Number>1</Aps:Number> <Aps:DateTime time="999886589338" search="20010403">04 03 2001 23:12:26 PDT </Aps:DateTime> <Aps:Comments>Data</Aps:Comments> <Aps:LocatorUrl>http://yahoo.com</Aps:LocatorUrl> <Aps:Accessor>edstar</Aps:Accessor> </Aps:Sheets> </Aps:Drawing> <Aps:Specification> <Aps:Type>text</Aps:Type> <Aps:Name>a file</Aps:Name> <Aps:Author>Amy</Aps:Author> <Aps:DocumentId>file.txt</Aps:DocumentId> <Aps:DocumentType>text/plain</Aps:DocumentType> <Aps:RevisionLevel>B</Aps:RevisionLevel> <Aps:Sheets id="269"> <Aps:Number>1</Aps:Number> <Aps:DateTime time="999886589338" search="20010823">08 23 2001 15:40:38 PDT </Aps:DateTime> <Aps:Comments>corrected to standard format</Aps:Comments> <Aps:LocatorUrl>http://google.com</Aps:LocatorUrl> <Aps:Accessor>ipteam</Aps:Accessor> </Aps:Sheets> </Aps:Specification> </Aps:AsDesigned> <Aps:AsBuilt> <Aps:SerialNumber>1088</Aps:SerialNumber> <Aps:TestResult> <Aps:Type>SC</Aps:Type> <Aps:Name>Report.SC.20010613.143351.xls</Aps:Name> <Aps:Author>Amy</Aps:Author> <Aps:DocumentId>Report.SC.20010613.143351.xls</Aps:DocumentId> <Aps:DocumentType>application/vnd.ms-excel</Aps:DocumentType> <Aps:RevisionLevel>1</Aps:RevisionLevel> <Aps:Sheets id="287"> <Aps:Number>1</Aps:Number> <Aps:DateTime time="999886589338" search="20010922">09 22 2001 12:18:48 PDT </Aps:DateTime> <Aps:Comments>Test Report for SC first</Aps:Comments> <Aps:LocatorUrl>http://yahoo.com/Z/CWSDVGetFileInfo?ipId=81,102,287</Aps:LocatorUrl> <Aps:Accessor>ipteam</Aps:Accessor> </Aps:Sheets> <Aps:TestConfiguration> <Aps:Type>SC Objects List</Aps:Type> <Aps:Name>ATE.SC.xls</Aps:Name> <Aps:Author>Amy</Aps:Author> <Aps:DocumentId>ATE.SC.xls</Aps:DocumentId> <Aps:DocumentType>application/vnd.ms-excel</Aps:DocumentType> <Aps:RevisionLevel>1</Aps:RevisionLevel> <Aps:Sheets id="283"> <Aps:Number>1</Aps:Number> <Aps:DateTime time="999886589338" search="20010922">09 22 2001 12:17:49 PDT </Aps:DateTime> <Aps:Comments>Includes Objects List</Aps:Comments> <Aps:LocatorUrl>http://yahoo.com/Z/CWSDVGetFileInfo?ipId=81,102,283</Aps:LocatorUrl> <Aps:Accessor>ipteam</Aps:Accessor> </Aps:Sheets> </Aps:TestConfiguration> </Aps:TestResult> </Aps:AsBuilt> <Aps:AsBuilt> <Aps:SerialNumber>1097</Aps:SerialNumber> </Aps:AsBuilt> <Aps:Cage>06887</Aps:Cage> </Aps:PartStructure> </Aps:VpmResultSet> ********************* and now the stylesheet <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:Aps="http://www.assist.com/" xmlns:xalan="http://xml.apache.org/xalan" xmlns:ino="http://namespaces.softwareag.com/tamino/response2" exclude-result-prefixes="Aps xalan ino"> <xsl:output method="html" indent="yes"/> <xsl:template match="/"> <xsl:for-each select="Aps:VpmResultSet/Aps:PartStructure/Aps:AsDesigned/Aps:Drawing"> <tr> <td><xsl:value-of select="ancestor::Aps:PartStructure/Aps:Name"/></td> <td><xsl:value-of select="ancestor::Aps:PartStructure/Aps:TopAssemblyName"/></td> <td><xsl:value-of select="ancestor::Aps:PartStructure/Aps:PartNumber"/></td> <td><xsl:value-of select="Aps:DocumentId"/></td> <td><a><xsl:attribute name="href">/assist/model/apsVpmSheets/?id=<xsl:value-of select="ancestor::Aps:PartStructure/@ino:id"/>&type=Aps:AsDesigned/Aps:Drawing&name=<xsl:value-of select="Aps:Name"/> </xsl:attribute><xsl:value-of select="Aps:Name"/> </a> </td> </tr> </xsl:for-each> <xsl:for-each select="Aps:VpmResultSet/Aps:PartStructure/Aps:AsDesigned/Aps:Specification"> <tr> <td><xsl:value-of select="ancestor::Aps:PartStructure/Aps:Name"/></td> <td><xsl:value-of select="ancestor::Aps:PartStructure/Aps:TopAssemblyName"/></td> <td><xsl:value-of select="ancestor::Aps:PartStructure/Aps:PartNumber"/></td> <td><xsl:value-of select="Aps:DocumentId"/></td> <td><a><xsl:attribute name="href">/assist/model/apsVpmSheets/?id=<xsl:value-of select="ancestor::Aps:PartStructure/@ino:id"/>&type=Aps:AsDesigned/Aps:Specification&name=<xsl:value-of select="Aps:Name"/> </xsl:attribute><xsl:value-of select="Aps:Name"/> </a> </td> </tr> </xsl:for-each> <xsl:for-each select="Aps:VpmResultSet/Aps:PartStructure/Aps:AsBuilt/Aps:TestResult"> <tr> <td><xsl:value-of select="ancestor::Aps:PartStructure/Aps:Name"/></td> <td><xsl:value-of select="ancestor::Aps:PartStructure/Aps:TopAssemblyName"/></td> <td><xsl:value-of select="ancestor::Aps:PartStructure/Aps:PartNumber"/></td> <td><xsl:value-of select="Aps:DocumentId"/></td> <td><a><xsl:attribute name="href">/assist/model/apsVpmSheets/?id=<xsl:value-of select="ancestor::Aps:PartStructure/@ino:id"/>&type=Aps:AsBuilt/Aps:TestResult&name=<xsl:value-of select="Aps:Name"/> </xsl:attribute><xsl:value-of select="Aps:Name"/> </a> </td> </tr> </xsl:for-each> </xsl:template> </xsl:stylesheet> Thanks! Amy XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] MSXML2 or MSXML ? That is the, Brad Crouch | Thread | RE: [xsl] for-each: is there a bett, Joshua . Kuswadi |
Re: [xsl] xt from a command line un, Raffaele Sena | Date | RE: [xsl] XSL-Fo and CSS, Joshua . Kuswadi |
Month |