You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Adam Flinton <ad...@nhs.net> on 2009/06/17 12:40:43 UTC

How to get required vs optional from a schema?

Dear All,

I am trying to build something which adds all required elements and
required attributes to a document but then gives a user a choice of
adding those child elements/attributes which are optional (via a web
app/gui).

So I have been looking walking the tree much as the
org.apache.xmlbeans.impl.xsd2inst.SampleXmlUtil does (except storing
elements etc into a dom structure).

So my question is:

If I find myself on an SchemaType (Element), how do I ask "what are my
required child nodes (elements & attribs)?" and "what are my optional
child nodes (elements & attribs)?"

TIA

Adam



********************************************************************************************************************

This message may contain confidential information. If you are not the intended recipient please inform the
sender that you have received the message in error before deleting it.
Please do not disclose, copy or distribute information in this e-mail or take any action in reliance on its contents:
to do so is strictly prohibited and may be unlawful.

Thank you for your co-operation.

NHSmail is the secure email and directory service available for all NHS staff in England and Scotland
NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and GSI recipients
NHSmail provides an email address for your career in the NHS and can be accessed anywhere
For more information and to find out how you can switch, visit www.connectingforhealth.nhs.uk/nhsmail

********************************************************************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: How to get required vs optional from a schema?

Posted by Radu Preotiuc-Pietro <ra...@oracle.com>.
Hi Adam,

There is no API to get that directly, but it is easy to get the info using SchemaType.getProperties(). Then, iterate over all properties, checkin for those that have .getMinOccurs() > 0. You get both elements and attributes, aggregated.

Radu

> -----Original Message-----
> From: Adam Flinton [mailto:adam.flinton@nhs.net] 
> Sent: Wednesday, June 17, 2009 6:41 AM
> To: XMLBeans-User
> Subject: How to get required vs optional from a schema?
> 
> Dear All,
> 
> I am trying to build something which adds all required 
> elements and required attributes to a document but then gives 
> a user a choice of adding those child elements/attributes 
> which are optional (via a web app/gui).
> 
> So I have been looking walking the tree much as the 
> org.apache.xmlbeans.impl.xsd2inst.SampleXmlUtil does (except 
> storing elements etc into a dom structure).
> 
> So my question is:
> 
> If I find myself on an SchemaType (Element), how do I ask 
> "what are my required child nodes (elements & attribs)?" and 
> "what are my optional child nodes (elements & attribs)?"
> 
> TIA
> 
> Adam
> 
> 
> 
> **************************************************************
> ******************************************************
> 
> This message may contain confidential information. If you are 
> not the intended recipient please inform the sender that you 
> have received the message in error before deleting it.
> Please do not disclose, copy or distribute information in 
> this e-mail or take any action in reliance on its contents:
> to do so is strictly prohibited and may be unlawful.
> 
> Thank you for your co-operation.
> 
> NHSmail is the secure email and directory service available 
> for all NHS staff in England and Scotland NHSmail is approved 
> for exchanging patient data and other sensitive information 
> with NHSmail and GSI recipients NHSmail provides an email 
> address for your career in the NHS and can be accessed 
> anywhere For more information and to find out how you can 
> switch, visit www.connectingforhealth.nhs.uk/nhsmail
> 
> **************************************************************
> ******************************************************
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org