List Info

Thread: How to get attributes from a XmlObject DomNode?




How to get attributes from a XmlObject DomNode?
user name
2007-09-10 05:11:13
Hi all,
 
How to get attributes from a XmlObject DomNode?
 
I have the following schema:
 
 <xs:complexType name="cardType">
 &nbsp; &nbsp; &nbsp;  <xs:sequence>
 &nbsp; &nbsp; &nbsp; &nbsp;   ; <xs:element name="available-credit" type="xs:int"/>
  ; &nbsp; &nbsp; &nbsp; &nbsp;  <xs:element name="credit-used" type="xs:int"/>
  ; &nbsp; &nbsp;  </xs:sequence>;
 &nbsp; &nbsp; &nbsp;  <xs:attribute name="name" use="required">
  ; &nbsp; &nbsp; &nbsp; &nbsp;  <xs:simpleType&gt;
 &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; <xs:restriction base="xs:NMTOKEN"&gt;
 &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ;  <xs:enumeration value="MasterCard"/>
   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp;  <xs:enumeration value="Visa"/>
&nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; </xs:restriction>
   ; &nbsp; &nbsp; &nbsp; &nbsp; </xs:simpleType&gt;
 &nbsp;   ; &nbsp; </xs:attribute&gt;
 &nbsp; &nbsp;   ; <xs:attribute name="number" type="xs:string" use="required"/>
 &nbsp;  </xs:complexType>
 
I use xmlbean to geneated&nbsp;the type jars and parse the belowing xml to be a CardType instance, when I want to get the attributes from XmlObject dom node, I get null(expect name and number attribute), from the internal node impl(_textsource) I find it's a document fragment (org.apache.xmlbeans.impl.store.Xobj$DocumentFragXobj), in org.w3c.dom.Node api, get attribute form document&nbsp;fragment  should be null, so are there some other way to get those attributes? (I don't know the exactly attributes the currenly XmlObject has)&nbsp;
 
<xml-fragment name="Visa" number="1111">
&nbsp; <available-credit>1000&lt;/available-credit>;
  <credit-used>2000</credit-used&gt;
</xml-fragment&gt;
 
 
Thanks a lot!
Terry
 
 
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )