[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: selecting elements depending on existence of attri

Subject: RE: selecting elements depending on existence of attributes
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Fri, 4 May 2001 11:01:29 +0100
formatting depending on existence
> There are some env-entry-name elements that have an attribute
> cols, some do
> not. If they have such an attribute, there could exist more than one
> env-entry-name elements with the same name as content.

I'm not sure I quite follow what you mean by "same name as content". But it
looks like a case for defining one template rule to handle each situation,
with a different match pattern for each. For example,

<xsl:template match="env-entry-name[@cols]">
...
</xsl:template>
<xsl:template match="env-entry-name[not(@cols)]">
...
</xsl:template>

>
> Now I want to include the different env-entry-value contents
> depending of
> the env-entry-name element cols attribute value, if there is
> not such an
> attribute, i.e. like in the third env-entry, the default content of
> env-entry-value should be included.

Sorry, I can't parse that sentence.
>
>
>
> My XSL looks like this at the moment:

I find it difficult to relate this to your problem description.
>
> --- snip ---
> <xsl:template name="include">
> 	<xsl:param name="key" />
> 	<xsl:variable name="includefile"
>
select="document('c:/dev/fbs/application/web/layouts/xml_to_jsp_include_02.x
ml')" />

The argument to document() must be a URI, not a filename.

> 	<xsl:value-of
> select="$includefile/properties/env-entry/env-entry-value[prec
> eding-sibling:
> :env-entry-name = $key and preceding-sibling::env-entry-name[@cols =
> $cols]]" disable-output-escaping="yes" />

Your code would be a lot simpler if you did this using xsl:apply-templates,
with different template rules for the different conditions.

You don't need preceding-sibling here: use something like
env-entry[env-entry-name[.=$key and @cols=$cols]/env-entry-value

What on earth is the disable-output-escaping for??

Mike Kay
Software AG


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.