[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: selecting elements depending on existence of attri
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|