[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-user
Subject:    RE: questions on XMLBeans
From:       "Radu Preotiuc-Pietro" <radup () bea ! com>
Date:       2007-05-23 1:43:41
Message-ID: 2C59DA782FCCE042AE3117F02628158309EF31 () rcpbex02 ! amer ! bea ! com
[Download RAW message or body]

That's not a problem. You would need to generate the containing
<xsd:schema> element yourself and then add type/element nodes to it.
Once you have that piece in place, the prefix declaration will show up
on the <xsd:schema> element. The prefix declaration has to appear
somewhere.

Radu

-----Original Message-----
From: Ajay Aggarwal [mailto:aaggarwal@covergence.com] 
Sent: Tuesday, May 22, 2007 12:37 PM
To: user@xmlbeans.apache.org
Subject: RE: questions on XMLBeans

Thanks again.

1. Yes.

2. Cool. That was really helpful. I was able to manipulate at DOM nodes
level to experiment generating my common.xsd. I still need to learn
cursor API. But I have a follow up question. My original XSD and
generated XSD files have slightly different structure. Are there any
options to save the generated XSD in the original format?

ORIGINAL XSD (just a snippet from the original)

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:complexType name="configClassesType">
    <xsd:sequence>
      <xsd:choice minOccurs="0" maxOccurs="unbounded">
        <xsd:element name="Cluster" type="ClusterType" />
        <xsd:element name="LocalBox" type="LocalBoxType" />
        <xsd:element name="Services" type="ServicesType" />
      </xsd:choice>
    </xsd:sequence>
  </xsd:complexType>

And GENERATED one (again the corresponding snippet)

<?xml version="1.0" encoding="UTF-8"?>
<xsd:complexType name="configClassesType"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:sequence>
      <xsd:choice minOccurs="0" maxOccurs="unbounded">
        <xsd:element name="Cluster" type="ClusterType"/>
        <xsd:element name="LocalBox" type="LocalBoxType"/>
        <xsd:element name="Services" type="ServicesType"/>
      </xsd:choice>
    </xsd:sequence>
  </xsd:complexType><?xml version="1.0" encoding="UTF-8"?>


Difference: difference is that the enclosing element '<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema">' is gone from the
generated one and instead it gets added to each global type element as
an attribute.

-----Original Message-----
From: Radu Preotiuc-Pietro [mailto:radup@bea.com]
Sent: Monday, May 21, 2007 5:34 PM
To: user@xmlbeans.apache.org
Subject: RE: questions on XMLBeans

Answers:

1. There is nothing special about simple types, so you would need to
decide the criteria to use (like facets and derivation). I would point
out however that minOccurs and maxOccurs are applicable for Schema
Properties in general, regardless if they are elements or not and
regardless of the their type (if they are elements).

2. Yeah, that is the basic answer. But, since you've asked, there is one
small thing that I usually don't recommend, but in your case I'm making
an exception because it could prove immensely useful: ((SchemaTypeImpl)
schemaType).getParseObject(). This is NOT guaranteed to be non-null
(depending on how you built your Schemas) but if it is non-null, it will
contain the XML representation (as an XmlObject) of the Schema type in
question (there is a similar method for SchemaGlobalElementImpl)

Good luck with your project,
Radu

On Mon, 2007-05-21 at 14:54 -0400, Ajay Aggarwal wrote:
> Thanks Radu.
> 
> 
> 
> So in order to compare 2 schemas for my use case, I am first building 
> the SchemaTypeSystem for each one and then recursively identifying the

> commonalities and differences between document types, global attribute

> types and global types. In order to compare two SchemaTypes, I am 
> recursively comparing their Attributes and Element Properties. In 
> order to compare two SchemaProperties, I am checking if they are 
> simple or complex. If complex I will recursively call compare on their

> SchemaTypes. For simple properties, I have question-1 below:
> 
> 
> 
> Question 1: How do I compare 2 simple SchemaProperties? Is their a 
> built-in function or do I need to compare myself their SchemaType, 
> DefaultText, MinOccurs, MaxOccurs etc?
> 
> 
> 
> Question 2: While doing above comparison, I need to build a 
> common.xsd, which will contain only the common definitions from two 
> schemas. As I identify the common types using above recursive 
> algorithm, how do I write out the common.xsd? I didn't see any call to

> say remove a property from a SchemaType. Is XmlCursor API the answer 
> to create and write the common.xsd? Is that the only answer?
> 
> 
> 
> Thanks again.
> 
> 
> 
> -Ajay
> 
> 
> 
> 
> 
> 
> ______________________________________________________________________
> From: Radu Preotiuc-Pietro [mailto:radup@bea.com]
> Sent: Thursday, May 17, 2007 12:38 PM
> To: user@xmlbeans.apache.org
> Subject: RE: questions on XMLBeans
> 
> 
> 
> 
> 1) No. There is no algorithm defined for doing a semantic diff between

> two Schemas, so we didn't spend the time to implement anything in this

> area. (as you have seen yourself, you don't even need a diff after 
> all, but something different) But using the SchemaType API you have 
> all you need to implement some custom logic appropriate to your 
> use-case.
> 
> 
> 
> 2) Yes, XmlBeans fully supports loading and manipulating invalid 
> Schema documents.
> 
> 
> 
> Radu
> 
> 
> 
> 
> ______________________________________________________________________
> From: Ajay Aggarwal [mailto:aaggarwal@covergence.com]
> Sent: Thursday, May 17, 2007 8:12 AM
> To: user@xmlbeans.apache.org
> Subject: RE: questions on XMLBeans
> 
> Let me further qualify point number 1 below. What I really need to do 
> is compare the two schemas and come up with a 3rd one which contains 
> only the common definitions.
> 
> 
> 
> 
> ______________________________________________________________________
> From: Ajay Aggarwal [mailto:aaggarwal@covergence.com]
> Sent: Thursday, May 17, 2007 11:05 AM
> To: user@xmlbeans.apache.org
> Subject: questions on XMLBeans
> 
> 
> 
> 
> I am evaluating XMLBeans for one of the projects. I have a few
> questions:
> 
> 
> 
> 1)       Does XML Beans provide any utility/hooks to compare two
> different schema files?
> 
> 2)       If my XML document deviates slightly from the underlying
> schema, can I still load it using XMLBeans... some sort of best effort

> XML to Java mapping?
> 
> 
> 
> Thanks.
> 
> 
> 
> Notice: This email message, together with any attachments, may contain

> information of BEA Systems, Inc., its subsidiaries and affiliated 
> entities, that may be confidential, proprietary, copyrighted and/or 
> legally privileged, and is intended solely for the use of the 
> individual or entity named in this message. If you are not the 
> intended recipient, and have received this message in error, please 
> immediately return this by email and then delete it.

Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

---------------------------------------------------------------------
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


Notice:  This email message, together with any attachments, may contain information  \
of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be \
confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended \
solely for the use of the individual or entity named in this message. If you are not \
the intended recipient, and have received this message in error, please immediately \
return this by email and then delete it.

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic