This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
multiple documents, namespaces and the same structure
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] multiple documents, namespaces and the same structure
- From: Dan Vint <dvint at slip dot net>
- Date: Wed, 10 Jan 2001 10:18:14 -0800 (PST)
- Cc: dvint at slip dot net (Dan Vint)
- Reply-To: xsl-list at lists dot mulberrytech dot com
I have an application that is made up of several small documents that each
have a DTD and their own namespace assignments. These documents all work
together and are linked via an attribute (href) that has the name of the
document file.
Within several of these I have a common address structure. Currently,
I process each document and address structure vi document() and then use
something like commercial:street or alob:street to format these documents.
What I want to do is create a standard template that I could pass the whole
address structure into and have it format everything. I beleive I'm being hung
up on the namespace names. If I take a simple version of the template it would
be like this:
Here is the call:
<xsl:for-each select="//commercial:business/commercial:us.address">
<xsl:call-template name="format.address">
<xsl:with-param name="address.node" select="."/>
</xsl:call-template>
</xsl:for-each>
the template:
<xsl:template name="format.address">
<xsl:param name="address.node"/>
<xsl:value-of select="$address.node"/>
<xsl:value-of select="$address.node/@address.type"/>
<xsl:value-of select="$address.node/street"/>
</xsl:template>
Data looks like:
<us.address address.type="street">
<street>222 Kearney St.</street>
<street>Suite 500</street>
<city>San Francisco</city>
<state>CA</state><zip main="94108" sub="1234"/>
</us.address>
This template will output:
222 Kearney St.Suite 500San FranciscoCA
street
<<nothing here for the third item>>
Any idea on how to set this up? I have other templates that I use generically
but I pass in specific values so I don't have the same problem. I suppose I
could do that here, but that would require changing every call to this template
if a new attribute or element is added to address - workable but not pretty.
thanks
..dan
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list