xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Murphy, Eric" <erimu...@pfc.cfs.nrcan.gc.ca>
Subject Fixed Attribute
Date Fri, 26 Mar 2004 16:45:22 GMT

XmlBeans -

I have a simple test schema which I have attached which declares some fixed
attributes.  Values for these attributes can be retrieved using the
corresponding getters from the document I create using XmlBeans.  However
validation of the document fails with messages saying there is nothing there
for these required attributes.

I find this behaviour incorrect.  Am I missing something?

Sample code:

    TopElementDocument doc = TopElementDocument.Factory.newInstance();
    TopElement top         = doc.addNewTopElement();
    SecondLevel second     = top.addNewSecondLevel();
    ThirdLevel third       = second.addNewThirdLevel();
    // print out the required fixed top_att, second_att, third_attr
    System.out.println("Value of topAttr = " + top.getTopAttr());    
    System.out.println("Value of secondAttr = " + second.getSecondAttr());
    System.out.println("Value of thirdAttr = " + third.getThirdAttr());
    ArrayList errorsList = new ArrayList();
    XmlOptions options = new XmlOptions().setErrorListener(errorsList);
    // Suprisingly errors here indicate the above attributes are missing

    // print out the document and see there is nothing there for the
    doc.save(System.out, options);

Output from above code:

Value of topAttr = top attribute
Value of secondAttr = second attribute
Value of thirdAttr = third attribute

[error: Expected attribute:  top_attr in element
 error: Expected attribute:  second_attr in element second_level, 
 error: Expected attribute:  third_attr in element third_level]

<?xml version="1.0" encoding="UTF-8"?>
<nfi:top_element xmlns:nfi="http://nfis.org/nfi">

Eric Murphy
Software Developer (NFIS)

tel/tél: 250-363-6038
fax / télécopieur 250-363-6004

Natural Resources Canada
Pacific Forestry Centre
506 West Burnside Road
Victoria BC V8Z 1M5

Ressources naturelles Canada
Centre de foresterie du Pacifique
506 rue Burnside ouest
Victoria, Colombie-Britanique V8Z 1M5

View raw message