This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: MSXML ancestor-or-self


Mitchel,
In that case you want all child nodes P
select="P"
and all preceding nodes P that don't have a preceding P with the same name
and don't have a name the same as any child nodes P of the current node.

select="P|preceding::P[@name != preceding::P/@name and @name !=
current()/P/@name]"

this doesn't work if your xml looks like this

<A>
	<P name="hello" value="blue"/>
	<P name="goodbye" value="redish"/>
	<P name="welcome" value="silver"/>
	<B>
		<P name="goodbye" value="red"/>
		<P name="hello" value="green"/>
		<C/>
	</B>
	<B>
		<P name="welcome" value="orange"/>
		<P name="hello" value="purple"/>
		<C/>
	</B>
</A>

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


>-----Original Message-----
>From: owner-xsl-list@lists.mulberrytech.com
>[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Richard
>Mitchell
>Sent: 07 March 2001 17:56
>To: 'xsl-list@lists.mulberrytech.com'
>Subject: RE: [xsl] MSXML ancestor-or-self
>
>
>
>First of all thanks Chris...
>
>Ok my example is a bit poor sorry for that but really my context is
>C with a file like...
>
><A>
> 	<P name="hello" value="blue"/>
>	<P name="aval" value="uppest"/>
>	<B>
>		<P name="bval" value="upper"/>
>		<P name="goodbye" value="red"/>
>		<P name="hello" value="green"/>
>		<C>
>			<P name="goodbye" value="yellow"/>
>		</C>
>		<P name="goodbye" value="orange"/>
>	</B>
></A>
>
>Expecting output like...
>;goodbye=yellow;hello=green;bval=upper;hello=uppest
>
>I've just experimented a little with the | operator but can't get
>anything sensible out of it
>
>> Richard,
>> You can't use ancestor-or-self in this case because of the
>> structure of you
>> xml. Look at it like this
>> <A>
>> 	<P name="hello" value="blue"/>
>> 	<B>
>> 		<P name="goodbye" value="red"/>
>> 		<P name="hello" value="green"/>
>> 		<C/>
>> 	</B>
>> </A>
>> If your context node is C then it's ancestors are B and A so
>> you need the
>> preceding axis
>> 	select="preceding::P"
>> This will give you all P nodes so you need to add a predicate
>> so that it
>> gives you only the nodes which don't have a preceding node
>> with the same
>> @name.
>> 	select="preceding::P[@name != preceding::P/@name]"
>>
>> Ciao Chris
>>
>> XML/XSL Portal
>> http://www.bayes.co.uk/xml
>>
>>
>> >-----Original Message-----
>> >From: owner-xsl-list@lists.mulberrytech.com
>> >[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Richard
>> >Mitchell
>> >Sent: 07 March 2001 15:12
>> >To: 'XSL'
>> >Subject: [xsl] MSXML ancestor-or-self
>> >
>> >
>> >Well it seems I've hit a small snag what I want
>> >is to get a list of variables in a scope so the
>> >closest is taken and passed on. The XML looks
>> >something like.
>> >
>> ><A>
>> ><P name="hello" value="blue"/>
>> >	<B>
>> >	<P name="goodbye" value="red"/>
>> >	<P name="hello" value="green"/>
>> >	<C/>
>> >	</B>
>> ></A>
>> >
>> >And my current context is C. With my output looking something like
>> >
>> >;hello=green;goodbye=red
>> >
>> >So far I've got
>> >	<xsl:for-each select="ancestor-or-self::*/p[ what on
>> earth can I put
>> >here ]">
>> >		;_<xsl:value-of select="@name"/>=<xsl:value-of
>> >select="@value"/>
>> >	</xsl:for-each>
>> >But I've got stuck in the way that MSXML3 seems to be serving up
>> >the axis in
>> >document order not reverse document order like it says on
>> P717 or Michael
>> >Kays
>> >excellent book.
>> >
>> >Any and all help would be appreciated.
>> >
>> >Richard Mitchell
>> >Software Developer
>> >http://www.vbnonline.com/
>> >
>> > XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>> >
>>
>>
>>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]