xsl-list
[Top] [All Lists]

RE: Can attribute names be compared !!

2003-08-27 10:19:13
Let me try to understand. You have selected an element which I will call
$E.

Your first statement of the requirement is:

I want to get data for all the nodes with the same 
name but having either less or same no. of attributes as this node

That sounds to me like:

//*[name() = name($E) and count(@*) <= count($E/@*)]

But of course the second part of the test is redundant if $E is the
element with the greatest number of attributes.

Your restatement of the requirement is completely different:

I want to compare 
the names of the attribute with the attribute names of the 
reference node and 
if they are same then outputting the value for that attribute 
otherwise outputting some other text (,or any kind of seperator).

This sounds to me like:

<xsl:for-each select="@*">
   <xsl:choose>
     <xsl:when test="$E/@*[name()=name(current())]">
       <xsl:value-of select="."/>
     </xsl:when>
     <xsl:otherwise>...</xsl:otherwise>
  </
</

With two such different statements of the requirement, it's hard to be
sure that I have understood either of them properly.

Michael Kay

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
Dipesh Khakhkhar
Sent: 27 August 2003 17:28
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Can attribute names be compared !!


Hi,

I asked this question twice or thrice with my xsl and xml 
pasted. But it seems 
that is making my email complicated and thats why i am not 
getting any 
replies.

So i will try to rephrase my problem.
I found out in a node in the xml having maximum attributes 
and I have stored 
it in the variable. Now if I want to get data for all the 
nodes with the same 
name but having either less or same no. of attributes as this 
node how do i 
get it. I mean i don't know the names of the attributes and I 
want to compare 
the names of the attribute with the attribute names of the 
reference node and 
if they are same then outputting the value for that attribute 
otherwise 
outputting some other text (,or any kind of seperator).

I hope this time my email being short I will get some reply.

Thanks !!

Regards,
Dipesh


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



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



<Prev in Thread] Current Thread [Next in Thread>