This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
xsl:with ?
- From: Jeff Beadle <Jbeadle at manh dot com>
- To: xsl-list <xsl-list at lists dot mulberrytech dot com>
- Date: Fri, 8 Mar 2002 11:46:08 -0500
- Subject: [xsl] xsl:with ?
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hello all,
I apologize up front for not being upto speed on what going on with xstl
2.0,
but I have a question for those who have:
Will there be anything like a "with" statement?
For example, in javascript I can do this:
var x = new ActiveXObject("MSXML2.DOMDocument.3.0");
with(x)
{
async = false;
validateOnParse = false;
if( ! loadXML(...) ) {
...
}
...
}
I make common use of this pattern within xslt, but I have to use a for-each.
For example:
<xsl:variable name="BaseElementInstance">
<BaseElement someAttribute="This is someAttribute"
someOtherAttribute="This is someOtherAttribute">
<ChildElement>blah blah</ChildElement>
</BaseElement>
</xsl:variable>
<xsl:for-each select="msxsl:node-set($BaseElementInstance)/BaseElement">
<DerivedElement>
<xsl:copy-of select="attribute::*[not(@someOtherAttribute)]"/>
<xsl:attribute name="someOtherAttribute">
Derived attribute 'someOtherAttribute' was overridden by
DerivedElement.
</xsl:attribute>
<xsl:copy-of select="descendant::*"/>
<DerivedElmentsChildElement/>
</DerivedElement>
</xsl:for-each>
So after too much detail (sorry), here's what I'd like to do:
Replace my xsl:for-each with an xsl:with.
For example:
<xsl:variable name="stuff">
...
</xsl:variable>
<xsl:with select="msxsl:node-set($stuff)/BaseElement">
...
</xsl:with>
The xsl:with implementation of 'select' would--in fact--be like:
select="msxsl:node-set($BaseElementInstance)/BaseElement[1]"
If the pattern query succeeds, it always uses the context of the first node
in
the resultant nodeset.
Anyhow, perhaps I'm just being lazy.
Thanks,
Jeff
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list