Re: Validation issues

2014-07-21 Thread jgagnon
Sorry for the confusion.  My application does not deal with the Java
implementation of any of the schema types.  It uses the information from the
schema to determine test cases to generate and then uses the XMLBeans API
(mainly XmlCursor) to create an XML instance.  Once the instance is complete
I then validate it via the XmlObject.validate(XmlOptions options) method and
save the object to a file.

One of the first things I do is to compile the schema XSD (with
XmlBeans.compileXsd(...)) to get a SchemaTypeSystem object. This provides me
with everything else I need.

The schema defines several abstract types, each of which has some number of
other schema types that extend them (i.e. ).  As the program works its way through a
document type to identify and generate test cases, when it encounters an
element defined by an abstract type, it scans the schema for any types that
extend that type.  It then generates the element with the type reference
attribute to point to the specific concrete schema type.  I also generate
the child content that is defined by the specific concrete type.

The generation logic inserts the namespace(s) as attributes of the root
element.  I insert the "default" namespace (i.e.
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";) and the
schema-specific namespace (e.g. xmlns:myPrefix="my-schema-site") ["myPrefix"
and "my-schema-site" are not the actual values used, of course].

As I mentioned, if I validate this using the XMLBeans command line
validator, there is no complaint, but when I used the API validator, I get
the error shown.

Regarding your comment on the schema version that is used, what can I do
about that?  I insert the "standard" XML heading into the file before
validating and saving.  E.g.   Does
the version number here indicate the schema version number?



--
View this message in context: 
http://xmlbeans.996285.n3.nabble.com/Validation-issues-tp7520p7523.html
Sent from the XMLBeans User mailing list archive at Nabble.com.

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



Validation issues

2014-07-16 Thread jgagnon
I have written an application that generates XML files that represent test
cases for a collection of types defined by an XML schema.  Some of these
types contain elements that are abstract.  The logic locates all concrete
implementers of the abstract type and when an instance is generated,
processes one of the concrete types in place of the abstract type.

It's my understanding that the element must have a type reference attribute
that indicates the concrete type name.  So, as an example:

...
  
... content ...
  
...

The schema defines the SomeElement field as being defined by an abstract
type.  ConcreteType is one of many possible concrete implementers of that
abstract type.

To take this a little further, a namespace entry is made in the document
that defines a prefix for the schema types.  So, in the root element there
would be entry like:

http://www.w3.org/2001/XMLSchema-instance";
xmlns:myPrefix="http://my-schema-site"/>

The prefix is applied to all elements that are defined by the schema.  E.g.
.  I would also assume that the prefix needs to be
used in the concrete type reference. So, what I have above now becomes:

...
  
... content ...
  
...

My application does all of this.

I have also added the option to validate the instance once it's been
generated.  *Here is where the problem enters the story.*  For some reason,
it fails validation with the complaint:

error: cvc-elt.4.2: Invalid xsi:type qname: 'myPrefix:ConcreteType' in
element SomeElement@my-schema-site

Oddly, if I validate the instance externally using XMLBeans validate utility
(.../xmlbeans-2.6.0/bin/validate), there is no complaint.

Am I doing something wrong?




--
View this message in context: 
http://xmlbeans.996285.n3.nabble.com/Validation-issues-tp7520.html
Sent from the XMLBeans User mailing list archive at Nabble.com.

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



XmlCursor tutorial

2014-06-24 Thread jgagnon
Does anyone know of any tutorials about using the XMLBeans XmlCursor?  I've
looked at the little bit on the XMLBeans site, but that really doesn't cover
much.  I'm trying to figure out how to use it to construct a document
(actually many documents - test cases) and it is anything but intuitive.  If
someone knows of a really well written, fairly comprehensive tutorial on its
usage, it would be very much appreciated.



--
View this message in context: 
http://xmlbeans.996285.n3.nabble.com/XmlCursor-tutorial-tp7515.html
Sent from the XMLBeans User mailing list archive at Nabble.com.

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



How to get an XmlObject parent

2014-05-16 Thread jgagnon
I am writing an application that uses the XMLBeans API to generate XML
instance documents.  In a nutshell I am doing this by creating XmlObject
instances and XmlCursors to make edits to the structure and content.  Once
the cursor has been placed properly, I insert/remove whatever I need
(comments, elements, text).

One problem I'm having, though, is generating a correct XPath format path to
be able to locate elements within the object hierarchy for editing.  I have
a mechanism in place now that uses something I came up with, and although it
works OK, it has some shortcomings.  I've had to come up with some kludgy
workarounds for some situations, for example abstract types.

I figured that it would make sense that the XmlObject family (including
XmlObject itself) would have the necessary attributes to allow for the path
to an element to be obtained simply by recursively checking for a "parent". 
However, there does not seem to be a provision for that capability, which I
find odd.

Does anyone have suggestions on how a given object in an XmlObject hierarchy
might be able to identify its path within the structure?



--
View this message in context: 
http://xmlbeans.996285.n3.nabble.com/How-to-get-an-XmlObject-parent-tp7506.html
Sent from the XMLBeans User mailing list archive at Nabble.com.

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



Difficulties with using XPath to find an element

2014-05-10 Thread jgagnon
I am programmatically generating an XML object hierarchy and then using what
I produced as a template for other work.  I make a copy of the template
structure (using XmlObject.copy() at the root node) and then attempt to
locate a specific node within the structure so that I can then edit the
structure (change element content, or add/remove elements).  I'm having a
problem getting the search to work.  I'm pretty sure I have all the
necessary jar files in the build path (probably more than I need).

When I inspect the XML of the object tree, it appears to have set the
default namespace (i.e. the root node contains: "xmlns:www.xyz.org" - no
prefix).  The elements are rendered with no namespace prefix as well.

When I was doing some earlier experimenting, I was parsing an existing XML
file and in this case, there was a namespace prefix in use, and I was able
to successfully "locate" elements.  Now I cannot, and I don't know why. 
Should I "turn on" a namespace prefix?  Is there some special XmlOption that
I should set?  Any ideas?



--
View this message in context: 
http://xmlbeans.996285.n3.nabble.com/Difficulties-with-using-XPath-to-find-an-element-tp7505.html
Sent from the XMLBeans User mailing list archive at Nabble.com.

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



Re: Dynamic generation of XML object hierarchy using schema

2014-05-06 Thread jgagnon
I assume that using the XmlCursor to build a document object hierarchy will
not make any use of the schema generated API?



--
View this message in context: 
http://xmlbeans.996285.n3.nabble.com/Dynamic-generation-of-XML-object-hierarchy-using-schema-tp7501p7503.html
Sent from the XMLBeans User mailing list archive at Nabble.com.

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



Dynamic generation of XML object hierarchy using schema

2014-05-06 Thread jgagnon
I am working on a project where we are trying to dynamically generate XML
instances, using the information gleaned from a defining XML schema.  The
instances will represent test cases for a given "message" type.

I've experimented with the XMLBeans schema type system to get useful
information about the types defined in the schema, such as the structure
(sequences, choices, etc.), min/max occurs and various restrictions
(enumerations, patterns, etc.). This information will be used to determine
what types of test cases will be generated for a given message element.

I'm at the point where I'd like to use the XMLBeans Java API to
programmatically generate XML document instances. Of course, I would need to
compile the schema to generate a Java library of classes that represent the
Java form of the message types (and supporting types).

What I don't know is how to dynamically use the generated API to create an
object hierarchy representing a test case.  The hierarchy would represent a
message instance (which may or may not be valid or complete based on the
test case), with element content populated with test data.

I cannot seem to find the information from the schema type system that would
allow me to "bridge" between the schema information and the specific
generated API classes that would need to be used to generate the object
hierarchy.

I assume if this information is available, I would then need to use
reflection to create the objects and set their values and attributes.

Does anyone have suggestions?



--
View this message in context: 
http://xmlbeans.996285.n3.nabble.com/Dynamic-generation-of-XML-object-hierarchy-using-schema-tp7501.html
Sent from the XMLBeans User mailing list archive at Nabble.com.

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



Getting namespace info from a parsed XML file

2014-05-01 Thread jgagnon
I'm trying to figure out how to get the namespace information (the
namespace(s) itself and the namespace prefix(es) that are applied to
elements within the document) contained within an XML file after I have
parsed it in XMLBeans.  For example, consider the following XML snippet:


http://www.domain.org/ ../schema.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:pfx="http://www.domain.org/";>
  

  
4142434445464748494a4b4c4d4e4f50

  
  This document is
UNCLASSIFIED

...


In the case, the namespace I'm concerned with is "http://www.domain.org"; and
the prefix "pfx" that's applied to the document elements.

I have not been able to figure out how to do this via the XMLBeans API.



--
View this message in context: 
http://xmlbeans.996285.n3.nabble.com/Getting-namespace-info-from-a-parsed-XML-file-tp7498.html
Sent from the XMLBeans User mailing list archive at Nabble.com.

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