This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
ancestor question
- To: XSL List <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] ancestor question
- From: Amy Kaizerman <amy dot j dot kaizerman at lmco dot com>
- Date: Thu, 27 Sep 2001 15:46:35 -0700
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi,
Here's my XML:
<?xml version="1.0"?>
<!DOCTYPE Aps:VpmResultSet SYSTEM
"http://sofa.atc.lmco.com/assist/config/dtd/ApsVpmQueryResponse.dtd">
<Aps:VpmResultSet xmlns:Aps="http://www.assist.com/">
<Aps:PartStructure>
<Aps:Name>assembly 1</Aps:Name>
<Aps:PartNumber>1</Aps:PartNumber>
<Aps:TopAssemblyName>pre assembly</Aps:TopAssemblyName>
<Aps:AsDesigned>
<Aps:Drawing>
<Aps:Name>drawing assembly 1-1</Aps:Name>
<Aps:DocumentId>314-1</Aps:DocumentId>
<Aps:Sheets>
<Aps:LocatorUrl>http://www.yahoo.com</Aps:LocatorUrl>
</Aps:Sheets>
</Aps:Drawing>
<Aps:Drawing>
<Aps:Name>drawing assembly 1-2</Aps:Name>
<Aps:DocumentId>314-2</Aps:DocumentId>
<Aps:Sheets>
<Aps:LocatorUrl>http://www.yahoo.com</Aps:LocatorUrl>
</Aps:Sheets>
</Aps:Drawing>
</Aps:AsDesigned>
</Aps:PartStructure>
<Aps:PartStructure>
<Aps:Name>assembly 2</Aps:Name>
<Aps:PartNumber>2</Aps:PartNumber>
<Aps:TopAssemblyName>pre assembly</Aps:TopAssemblyName>
<Aps:AsDesigned>
<Aps:Drawing>
<Aps:Name>drawing assembly 2</Aps:Name>
<Aps:DocumentId>315</Aps:DocumentId>
<Aps:Sheets>
<Aps:LocatorUrl>http://www.yahoo.com</Aps:LocatorUrl>
</Aps:Sheets>
</Aps:Drawing>
</Aps:AsDesigned>
</Aps:PartStructure>
</Aps:VpmResultSet>
Here's my XSL:
<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"
exclude-result-prefixes="Aps">
<xsl:output method="html" indent="yes"/>
<xsl:param name="Name" select="."/>
<xsl:template match="/">
<xsl:for-each select="Aps:VpmResultSet/Aps:PartStructure">
<xsl:for-each select="xalan:evaluate($Name)">
<tr>
<td><xsl:value-of
select="ancestor::Aps:VpmResultSet/Aps:PartStructure/Aps:Name"/></td>
<td><xsl:value-of
select="ancestor::Aps:VpmResultSet/Aps:PartStructure/Aps:TopAssemblyName"/></td>
<td><xsl:value-of
select="ancestor::Aps:VpmResultSet/Aps:PartStructure/Aps:PartNumber"/></td>
<td><xsl:value-of select="Aps:DocumentId"/></td>
<td><a><xsl:attribute name="href">
<xsl:value-of select="Aps:Sheets/Aps:LocatorUrl"/>
</xsl:attribute><xsl:value-of select="Aps:Name"/>
</a>
</td>
</tr>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I'm getting (I've ignored the href part for now):
<tr>
<td>assembly 1</td> <td>pre assembly</td> <td>1</td>
<td>314-1</td> <td>drawing assembly 1-1</td></tr>
<tr>
<td>assembly 1</td> <td>pre assembly</td> <td>1</td>
<td>314-2</td> <td>drawing assembly 1-2</td> </tr>
<tr>
<td>assembly 1</td> <td>pre assembly</td> <td>1</td>
<td>315</td> <td>drawing assembly 2</td></tr>
but what I want is:
<tr>
<td>assembly 1</td> <td>pre assembly</td> <td>1</td>
<td>314</td> <td>drawing assembly 1</td></tr>
<tr>
<td>assembly 1</td> <td>pre assembly</td> <td>1</td>
<td>314-2</td> <td>drawing assembly 1-2</td> </tr>
<tr>
<td>assembly 2</td> <td>pre assembly</td> <td>2</td>
<td>315</td> <td>drawing assembly 2</td></tr>
The xalan:evaluate() is sent in from a setParameter("Name", param) and
seems to be working correctly.
In this case param would be Aps:AsDesigned/Aps:Drawing, however I've
just shown a section of the
true XML. This param could be at different levels although the children
will look the same.
The xalan:evaluate section seems to work, it's just that I also need the
ancestor information in the
table and that doesn't seem to be doing what I thought it would.
Could someone please tell me why this doesn't work and how I should go
about fixing it?
Thanks!
Amy
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list