RE: [xsl] preceding-sibling

Subject: RE: [xsl] preceding-sibling
From: "Borca, Olivier" <Olivier.Borca@xxxxxxxxxxxxxxxx>
Date: Tue, 13 Mar 2001 14:28:29 +0100
ok let's be more precise then :)
if I create an element with the name :
"{preceding-sibling::element[position()=1]/@type}foo",
I have an object created which name is ... "foo" ! ;)
The 'preceding-sibling::element[position()=1]/@type' doesnt give me any
result.

And I am using Xalan parser.
Btw, thx a lot to all of you who help me !

The input document is the following (excerpt):

<ElementType name="CIM_ActiveConnection" content="eltOnly">
	<AttributeType name="SUPERCLASS" required="yes"/>
	<attribute type="SUPERCLASS"/>
	<group order="seq">
		<element type="IsUnidirectional"/>
		<element type="OtherTrafficDescription"/>
		<element type="TrafficType"/>
		<element type="TrafficTypeValueMap"/>
		<element type="CIM_ProtocolEndpointAntecedent"/>
		<element type="CIM_ProtocolEndpointDependent"/>
	</group>
</ElementType>

What I want to do is when I parse an element which name is the name of
the preceding element concatenated to "ValueMap", I have have a special
formatting of data. In this example, the test would answer true for
"TrafficTypeValueMap" because its preceding element is "TrafficType".
I don't know if it's clear but ... this is what I use in my XSL:

<xsl:template match="xd:element">
	<xsl:copy>		
		<xsl:attribute name="type">
			<xsl:value-of select="@type" />
		</xsl:attribute>
		<xsl:choose>				
			<xsl:when
test="not(/xd:Schema/xd:ElementType[@name=current()/@type]/xd:group)">

				<xsl:attribute name="sql:field">
					<xsl:value-of select="@type" />

				</xsl:attribute>
			</xsl:when>
			<xsl:otherwise>

				<xsl:choose>
--->					<xsl:when test="@type =
concat(preceding-sibling::element[1]/@type,'ValueMap')">
						<xsl:element
name="sql:relationship">
							<xsl:attribute
name="key-relation">
	
<xsl:value-of select="../../@name" />
	
</xsl:attribute>
							<xsl:attribute
name="key">
	
<xsl:value-of select="preceding-sibling::element[position()=1]/@type" />
							</xsl:attribute>
							<xsl:attribute
name="foreign-key">ValueMap</xsl:attribute>
							<xsl:attribute
name="foreign-relation"><xsl:value-of select="@type" /></xsl:attribute>
			      		</xsl:element>
					</xsl:when>
					...

If you have any idea ...

-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: Tuesday, March 13, 2001 2:07 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] preceding-sibling



> In fact the "preceding-sibling::element[position()=1]" doesnt work at
> all .. 

Go on, give us a clue:-)

what's the input look like, what is the context node when you evaluate
this expression. When you say "it doesn't work" do you mean you get th
ewrong thing? you get nothing? you get an error?

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered
through the MessageLabs Virus Control Centre. For further information
visit
http://www.star.net.uk/stats.asp

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


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


Current Thread