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]
Other format: [Raw text]

XPath problem



Hi List,

I have my XML as follows

<records>
     <record1 type="type1">
          <field1 value="xyz">
     </record1>

     <record1 type = "type2">
     </record1>
</records>

If I am looking for an element which does not happen to be an attribute my
logic below works fine in getting the nearest "@type" value on the ancestor
axis.

NodeList nl = XPathAPI.eval(root, //xs:field1,prefixResolver).nodelist()
and then for each Node instance I can get the nearest "@type" value by
doing something like this

 XObject obj = XPathAPI.eval(currentRecord1Node,"ancestor::
*[@type][1]/@*[name()='type']",prefixResolver);
 String result = obj.toString();

I run into problem when what I am looking happens to be an Attribute e,g
"value". So, if my "currentRecord1Node" is for this attribute element
"value", I am loosing my Node structure information and I am unable to get
to the nearest "@type" value.

Is there anyway I can get the Node information even though I am searching
on an Attribute element?

Any help / links / pointers would be highly appreciated.

Thanks,
Sanjay


 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]