Thanks - that works!
Even after having used XmlBeans for a while I still confuse elements
and types :^(. However, the error message was rather misleading. My debugger
clearly showed that schemaObject was, indeed, a document with the root
element <xs:schema>. After selecting the first child, you have a
<xml-fragment>
with all of the schema elements as children, not a "schema document"
as the error message states.
- Andy
Radu Preotiuc-Pietro wrote:
It seems to me you have to go one level down to get to the schema, for example
schemaObject.selectChildren(new QName("http://www.w3.org/2001/XMLSchema",
"schema"));
Radu
-----Original Message-----
From: Andy Putnins [mailto:[email protected]]
Sent: Monday, March 02, 2009 1:50 PM
To: [email protected]
Subject: How to change SchemaType to XML Schema?
If I have a document that contains an embedded XML Schema,
how can I change the SchemaType of the <xs:schema> element
from an element of the containing document type? One way to
do it would be to convert it to a string and compiling it,
but that seems like a waste.
When I attempt to execute this:
SchemaTypeSystem sts = XmlBeans.compileXsd(
new XmlObject[] { schemaObject },
XmlBeans.getBuiltinTypeSystem(),
compileOptions);
I get the following error:
org.apache.xmlbeans.XmlException: Thread main: The 0th
supplied input is not a schema document: its type is
E=configSchema|t=metadatat...@http://lett.com/ns/netconf/serve
r/meta/1.0
at
org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler.compi
le(SchemaTypeSystemCompiler.java:211)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccess
orImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMeth
odAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.xmlbeans.XmlBeans.compileXmlBeans(XmlBeans.java:667)
at org.apache.xmlbeans.XmlBeans.compileXsd(XmlBeans.java:553)
at
com.lett.netconf.server.db.ManagedDevice$Metadata$Schema.compi
le(ManagedDevice.java:781)
at
com.lett.netconf.server.db.ManagedDevice$Metadata$Schema.<init
(ManagedDevice.java:658)
at
com.lett.netconf.server.db.ManagedDevice$Metadata.<init>(Manag
edDevice.java:416)
at
com.lett.netconf.server.db.ConfigServerDevice.<init>(ConfigSer
verDevice.java:105)
at com.lett.netconf.server.db.Storage.<init>(Storage.java:173)
at com.lett.netconf.server.db.Storage.<init>(Storage.java:123)
at
com.lett.netconf.server.NetconfServerDaemon.<clinit>(NetconfSe
rverDaemon.java:183)
schemaObject is an XmlObject that is a document with the root
element <xs:schema>. It was extracted from the configSchema
element of a document of type metadataType. The configSchema
element has a single child element of type <xs:any>, which is
the schema.
- Andy
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]