[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: check if a* not equal to attribute value
> -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Bryan > Rasmussen > Sent: 31 January 2002 09:38 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: check if a* not equal to attribute value > > 1. I have a node with a bunch of attributes, a* if any of > these attributes > names are not the same as the value of the attribute name in > some xpath then > I want to copy them over to my result tree. > > currently what I have, which is working, is the following: > > > <xsl:template match="fo:*[@it:class]" priority="2"> > <xsl:variable name="itclass"><xsl:value-of > select="@it:class"/></xsl:variable> > > <xsl:element name="{name()}"> > <xsl:for-each select="@*"><xsl:copy/></xsl:for-each> > <xsl:for-each select="$cssdocSelect//selector[@it:class=$itclass]/s"> > <xsl:attribute name="{@name}"><xsl:value-of select="."/> > </xsl:attribute> > </xsl:for-each> > <xsl:apply-templates/> > </xsl:element> > </xsl:template> > > I think this will break on some processors, right, or give me > at least the > opposite of what I want, dependant on processing > order. interesting question: does anyone know of a processor > in which this > would give the opposite of what I want? I'm not entirely clear what you do want, but I can't see anything in the above that could give different results on different processors. If you write two attributes with the same name, the one written "later" is guaranteed to win: this is based not on the order of execution, but on the position of the two attributes in the result sequence. Admittedly the XSLT 1.0 spec isn't very formal on this, this is something we tried to improve in the 2.0 draft. Your code does seem a bit convoluted, it could be rewritten as: > <xsl:template match="fo:*[@it:class]" priority="2"> > <xsl:variable name="itclass" select="@it:class/> > > <xsl:copy> > <xsl:copy-of select="@*"/> > <xsl:for-each select="$cssdocSelect//selector[@it:class=$itclass]/s"> > <xsl:attribute name="{@name}"> <xsl:value-of select="."/> > </xsl:attribute> > </xsl:for-each> > <xsl:apply-templates/> > </xsl:copy> > </xsl:template> > > anyway the question is how to find out if any @* name is not equal to > $cssdocSelect//selector[@it:class=$itclass]/s[@name] Your code achieves this, and is probably the simplest way of achieving it at XSLT 1.0. In XSLT 2.0 you could write something like <xsl:copy-of select="@*[every $x in $cssdocSelect//selector[@it:class=$itclass]/s satisfies name($x) != name(.)]"/> but I don't think I would bother. Mike Kay 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
|