Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

dom4j / default attributes?

Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am currently using dom4j to parse an xml document. The problem is - in my xml schema (.xsd) file I am specifying a default value for an attribute i.e.:
<xs:attribute name="attr01" type="xs:string" default="some value"/>
Then in my .xml which is based on the .xsd i.e.:
<foo attr01="why does the one below not default to 'some value'">
<bar>This foo has an attr01 set</bar>
<bar>This foo has no attr01, why doesn't it get the default?</bar>
When I parse this .xml in dom4j iterating thru the attributes of the foo elements - it doesn't give me the default value in the second foo element.
I think I can understand this as dom4j doesn't seem to be tied to the schema really.
So the question is how can I parse an .xml doc and retain default values that were specified in schemas for certain attributes? I would like to use dom4j to do this, but I would be open to others. (BTW, I have already successfully done it with jaxb - but I don't think I want to use that method due to other constraints of my application).
Many Thanks!
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic