> I thought my original explanation was a little confusing (ok very
> confusing).
> I got things working as I wanted after changing the xml file tags and
> adding attributes.
> Here is what I ended up with, what other approach would you have taken?
>
> Also is it more efficient to declare billto as a string and pass as a
> parameter and declare
> the document in the apply-templates select, like below. Or to declare
> billto as a document
> initially and pass the node set as the parameter.
>
> Thanks,
> Rich
Hello Rich,
your stylesheet looks really good. Only some little changes according
the variable usage: A variable is more or less useless, if you can't use
it multiple times.
========================= mergeXML.xsl ===============================
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
Really version="2.0"? Only Saxon supports the Working Draft version of
XSLT and XPath 2.0.
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/invoice-xml-files">
<xsl:variable name="TA-Parties"
select="document(@bill-to)/TRANSACTION_PARTIES/TRANSACTION_PARTY"/>
I suggest to declare the node set once. Look at the further changes.
<html>
<head>
<title>
This is driving me out of my mind!!!!
</title>
</head>
<body>
<xsl:apply-templates
select="document(@invoice-header)/INVOICES/INVOICE">
<xsl:with-param name="TA-Parties" select="$TA-Parties"/>
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="INVOICES/INVOICE">
<xsl:param name="TA-Parties"/>
<hr/>
<h3>INVOICE HEADER RECORD</h3>
<xsl:apply-templates
select="$TA-Parties[(_at_)account=current()/@account and
type='BILL_TO']"/>
<xsl:apply-templates/>
</xsl:template>
<!-- Invoice header templates go here -->
<xsl:template match="TRANSACTION_PARTY">
<xsl:text>Bill To:</xsl:text><br/>
<xsl:value-of select="NAME"/><br/>
<xsl:value-of select="ADDRESS1"/><br/>
<xsl:value-of select="ADDRESS2"/><br/>
<xsl:value-of select="CITY"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="STATE"/>
<xsl:text> </xsl:text>
<xsl:value-of select="ZIPCODE"/><br/>
</xsl:template>
</xsl:stylesheet>
========================== mergeXML.xsl ==========
I hope I did no mistakes.
The next time please send the XML with the question, this solves mostly
the confusion.
Regards,
Joerg
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list