XML Schema Substitution Group
Hi,
Can anybody please explain what are ***Substitution Groups*** in XML Schema with a simple example as this concept is little bit fuzzy for me.
Thanks.
This concerns with internationalization (i18N):
http://www.w3schools.com/schema/schema_complex_subst.asp
Similar Messages
-
Element's substitution group with Xerces Schema API
Hi,
I am using Xerces Schema API and I can not figure out how to find an element's substitution group. There are some methods in XSElementDeclaration that look like they could help but they return null even if globally defined element has a substitution group. Any help would be greatly appreciated.
ThanksUpps...please ignore this post.
-
Specifying Case-Insensitive Element Names in XML Schema
Hope someone knows this!
Is it possible to define an an XML Schema Definition so that Element names in the target XML File can be case insensitive.
At the moment my Parser throws an error if the element names in the XML file do not have the exact same case as the definition in the XML schema.
E.g
In Schema i have:
<xsd:element name="HOSTINVENTORYLINE" type="HostInventoryLineType" maxOccurs="unbounded" minOccurs="0"/>
but in xml file i have
<HostInventoryLine field=""/>
or
<hostinventoryline field=""/>
Does anyone know anyway to get around this, so that the parser accepts the HostInventoryLine element in the xml as an instance of the HOSTINVENTORYLINE element defined in the schema.
Thanks in Advance
JJ
Message was edited by:
[email protected]You could use substitution groups to handle this. You would need an entry in the schema for each valid capitalization. This won't scale well if you want to be completely case insensitive, but if you only support lower case, upper case, and camel case it should do the trick.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="HostInventoryLineType">
<xs:sequence>
<xs:element name="an-element" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="HostInventoryLine" type="HostInventoryLineType"/>
<xs:element name="HOSTINVENTORYLINE" type="HostInventoryLineType" substitutionGroup="HostInventoryLine"/>
<xs:element name="hostinventoryline" type="HostInventoryLineType" substitutionGroup="HostInventoryLine"/>
</xs:schema>-Blaise -
Substitution groups support?
Does xmlbeans support substitution groups in xml schema? I read xml beans documentation
saying it has 100% xml schema support. But I got the following error when I use
xmlbeans to generate java classes:
[xmlbean] ObjectLinking.xsd:27: warning: Element substitution groups not supported
in this release
I appreciate if anyone can help me on this.Does xmlbeans support substitution groups in xml schema? I read xml beans documentation
saying it has 100% xml schema support. But I got the following error when I use
xmlbeans to generate java classes:
[xmlbean] ObjectLinking.xsd:27: warning: Element substitution groups not supported
in this release
I appreciate if anyone can help me on this. -
Problem with abstract complex type in substitution group.
Hi all,
I have three xsds, A, B, C.XSD respectively. A.xsd:There is a substitution group and its complex type declared as abstract and element that uses them. B.xsd has the same structure as A except that it has complex type derived from complex type from A. C.xsd is same as B.xsd.
The xml files of A and B validate but not of C.
It gives the following error:
This file is not valid. Unexpected element'signatureString' in element author. Expected signatureString,signatureText.
Any help at the earliest is greatly appreciated.
the code of each xsds is as follows:
A.XSD:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:PARTICIPATION="Participation" targetNamespace="Participation">
<!-- ================================================= -->
<!-- Package: Participation -->
<!-- ================================================= -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Class: <<ST>> SignatureString -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<xs:element name="signatureString" type="PARTICIPATION:SignatureString" substitutionGroup="PARTICIPATION:signatureText"/>
<xs:complexType name="SignatureString">
<xs:complexContent>
<xs:extension base="PARTICIPATION:SignatureText">
<xs:attribute name="value" type="xs:string" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Class: SignatureText -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<xs:element name="signatureText" type="PARTICIPATION:SignatureText" abstract="true"/>
<xs:complexType name="SignatureText" abstract="true"/>
</xs:schema>
B.xsd:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:CM3202="Common3202" xmlns:PARTICIPATION="Participation" targetNamespace="Common3202">
<xs:import namespace="Participation" schemaLocation="Datatypes3203/RDT/Participation.xsd"/>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Class: <<Participation>> PractitionerParticipation -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<xs:element name="practitionerParticipation" type="CM3202:PractitionerParticipation" abstract="true"/>
<xs:complexType name="PractitionerParticipation" abstract="true">
<xs:sequence>
<!--xs:element name="signatureText" type="PARTICIPATION:SignatureText" minOccurs="0"/-->
<xs:element ref="PARTICIPATION:signatureText"/>
</xs:sequence>
</xs:complexType>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Class: <<Participation>> Author -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<xs:element name="author" type="CM3202:Author" substitutionGroup="CM3202:practitionerParticipation"/>
<xs:complexType name="Author">
<xs:complexContent>
<xs:extension base="CM3202:PractitionerParticipation"/>
</xs:complexContent>
</xs:complexType>
</xs:schema>
C.xsd
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:VS3203="VitalSigns3203" xmlns:CM3202="Common3202" targetNamespace="VitalSigns3203">
<xs:import namespace="Common3202" schemaLocation="Common3202.xsd"/>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Class: <<Observation>> VitalSignsObservationEvent -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<xs:element name="vitalSignsObservationEvent" type="VS3203:VitalSignsObservationEvent"/>
<xs:complexType name="VitalSignsObservationEvent">
<xs:sequence>
<xs:element name="author" type="CM3202:Author" minOccurs="0">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>Hi all,
This seems to be a bug unless someone of you have a solution.
Also I ma new to xml/xsd world, so could someone please give the differences between xsi:type vs substitution groups with both element and complex type being abstract. Can this scenario be accomplished by usuage of choice groups.
Also can anyone suggest any other good xml forums.
Please let me know.
Thanks in advance. -
JAXB: Abstract Types and Substitution Group Errors
I am using several schemas as defined below:
Schema 1 defines an abstract type
Schema 2 extends abstract type
Schema 3 makes reference to abstract type in 1 and is using substitution groups on the abstarct type
The error only occurs when the element is Abstract and what extends
the abstract element specify a substitution group (which I believe is
correct according to
http://www.w3.org/TR/2001/REC-xmlschema-0-20010502/#abstract). I can't
remove the substitution group because declaring the element as abstract
requires this. Is there a way to fix this?
code that generates error:
When attempting to do a JAXBContext jaxbContext = JAXBContext.newInstance(Schema3.class) I get the following error
Exception in thread "main" com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
There's no ObjectFactory with an @XmlElementDecl for the element {[http://test.com/FeatureBase.xsd|http://seams.csp.com/FeatureBase.xsd]}FeatureBase.
this problem is related to the following location:
at com.test.blah
at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:448)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:297)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:139)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:214)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:375)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)Hi all,
This seems to be a bug unless someone of you have a solution.
Also I ma new to xml/xsd world, so could someone please give the differences between xsi:type vs substitution groups with both element and complex type being abstract. Can this scenario be accomplished by usuage of choice groups.
Also can anyone suggest any other good xml forums.
Please let me know.
Thanks in advance. -
I need a sample about how substitution groups are rewrited
Hi
As mentioned in a documentation, substitution groups in 10g are rewritten:
The XML Schema constructs for the XPath expression are rewritable.
XML Schema constructs such as complex types, enumerated values, lists, inherited (derived) types, and substitution groups are rewritten.
Can anybody give me a link to a topic or a blog where this subject is discussed?
I'm very need to.
Thanks
DmitryHi
As mentioned in a documentation, substitution groups in 10g are rewritten:
The XML Schema constructs for the XPath expression are rewritable.
XML Schema constructs such as complex types, enumerated values, lists, inherited (derived) types, and substitution groups are rewritten.
Can anybody give me a link to a topic or a blog where this subject is discussed?
I'm very need to.
Thanks
Dmitry -
Problems using mathml XML Schema in XMLDB
I have successfully loaded the hierarchy of XML Schema definition documents for the current 'mathml' by adjusting the relative paths in all include and import statements, and by forcing the load to overcome cyclic dependency issues.
However when I try to create a table using the XMLTYPE or register another schema which is dependent on mathml I receive the following error:
ERROR at line 1:
ORA-31079: unable to resolve reference to group "Content-expr.class"
ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 37
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 61
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 126
ORA-06512: at line 14
Having tried loading into both 9iR2 and 10GR2 databases and pasting the document containing the 'Content-expr.class' into the parent document (i.e. removing the include) I have come to the conclusion that there is a problem with the schema definition.
However being new to XML I do not know what ths issue is as the file containing the definition (math.xsd) is included well before the references in the parent document.
Here is the group definition corresponding to the offending reference:
<xs:group name="Content-expr.class">
<xs:choice>
<xs:group ref="ContExpr.class"/>
<xs:group ref="PresExpr.class"/>
</xs:choice>
</xs:group>
I am also unable to trace which reference is causing the problem as there are several.
Does anyone have any suggestions as to what could be causing this issue, or how I can obtain further diagnostics?
Any help much appreciated.
Robert Honeyman
*********** New info ***************
OK. I have tried further to register the schema, and have the following additional information.
I determined that I thought my problem was cyclic dependencies being resolved ONLY by virtue of the parent file mathml2.xsd. I therefore pasted all the files together in include order so that this was no longer an issue. I then performed the following actions:
1. I tried to register into Oracle 9iR2 database (9.2.0.4) and received the following error:
ERROR at line 1:
ORA-31151: Cyclic definition encountered for group: "Content-expr.class"
ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 0
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 26
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 131
ORA-06512: at line 14
2. I then tried registering the schema into an Oracle 10G Release 2 database as well, and received the following error:
ORA-31084: error while creating table "MEDLINE"."math729_TAB" for element
"math"
ORA-01792: maximum number of columns in a table or view is 1000
ORA-02310: exceeded maximum number of allowable columns in table
ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 37
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 61
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 126
ORA-06512: at line 14
My conclusions are as follows:
1. 9iR2 (the version I was using at least 9.2.0.4) can't handle cyclic dependencies at all, or at least not complex ones.
2. Neither 9iR2 or 10gR2 can handle cyclic dependencies (or other dependent definitions managed purely by virtue of a parent file with multiple include statements)
3. 10gR2 can handle cyclic dependencies when they are all defined in the same file or resolved by an explicit include regardless of complexity.
4. 10gR2 cannot handle highly complex XML Schema definitions due its limit of 1000 columns per table.
Does anyone have any comments on these conclusions?
I don't even want to handle Mathml, just another schema definition that imports it. I may try to make my own adjustments.
Message was edited by:
rhoneyman
nullThanks, I found the relevant sections in the XML DB 10GR2 documentation (chapter 3 I think). As far as I can tell my options are to either use one of the following:
- top-down technique creating tables for sub elements in the schema definition
- bottom-up technique collapsing some of the lower elements into CLOBs (I guess this is semi-structured storage)
The problem with Mathml is that it seems quite complex, with only one global schema element and many nested elements, hence only one table is created by XMLDB and it logically follows that we run out of columns.
To get it to work is likely to involve a fair amount of manual schema modification, which incurs a maintenance overhead for me.
It would be good if Oracle could provide a way of simplifying this maintenance of complex schemas to get them to be registered. I guess this would be increasing the number of columns alllowed for a table or offering some other parametric option for DBMS_XMLSCHEMA.REGISTER_SCHEMA that allowed a threshold and either a top-down or bottom-up approach to be taken automatically.
For the time being I am using a simplified schema that does not depend on Mathml for my storage needs. -
Hi all,
I just got a copy of the book "Pro SQL Server 2008 XML" written by Michael Coles (published by Apress) and try to learn the XML Schema Collection in my SQL Server 2012 Management Studio (SSMS2012). I studied Chapter 4 XML Collection of the book
and executed the following code of Listing 4-8 Complex Schema with Attribute:
-- Pro SQL Server 2008 XML by Michael Coles (Apress)
-- Listing04-08.sql Complex XML Schema with Attribute
-- shcColes04-08.sql saved in C:\\Documents\XML_SQL_Server2008_code_Coles_Apress
-- 6 April 2015 8:00 PM
CREATE XML SCHEMA COLLECTION dbo.ComplexTestSchemaCollection_attribute
AS
N'<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="item">
<xs:complexType>
<xs:sequence>
<xs:element name="name" />
<xs:element name="color" />
<xs:group ref="id-price" />
<xs:group ref="size-group" />
</xs:sequence>
<xs:attribute name="id" />
<xs:attribute name="number" />
</xs:complexType>
</xs:element>
<xs:group name="id-price">
<xs:choice>
<xs:element name="list-price" />
<xs:element name="standard-cost" />
</xs:choice>
</xs:group>
<xs:group name="size-group">
<xs:sequence>
<xs:element name="size" />
<xs:element name="unit-of-measure" />
</xs:sequence>
</xs:group>
</xs:schema>';
GO
DECLARE @x XML (dbo.ComplexTestSchemaCollection_attribute);
SET @x = N'<?xml version="1.0"?>
<item id="749" number="BK-R93R-62">
<name>Road-150 Red, 62</name>
<color>Red</color>
<list-price>3578.27</list-price>
<size>62</size>
<unit-of-measure>CM</unit-of-measure>
</item>';
SELECT @x;
GO
DROP XML SCHEMA COLLECTION dbo.ComplexTestSchemaCollection_attribute;
It worked nicely. But, I just found out the coding that was downloaded from the website of Apress and I just executed was different from the coding of Listing 4-8 listed in the book: all the <xs: ....> and </xs: ..> in my SSMS2012 are
listed as <xsd:...> and </xsd:...> respectively in the book!!?? The same thing happens in the Listing 4-3 Simple XML Schema, Listing 4-5 XML Schema and Valid XML Document with Comple Type Definition, Listion 4-6 XML Schema and XML
Document Document with Complex Type Using <sequence> and <choice>, and Listing 4-7 Complex XML Schema and XML Document with Model Group Definition (I executed last week) too. I wonder: should xs or xsd be used in the XML
Schema Collection of SSMS2012? Please kindly help, clarify this matter and explain the diffirence of using xs and xsd for me.
Thanks in advance,
Scott ChangHi Scott,
Using xs or xsd depends on how you declare the namespace prefix.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="item">
I've posted a very good link in your last question, just in case you might have missed it, please see the below link.
Understanding XML Namespaces
In an XML document we use a namespace prefix to qualify the local names of both elements and attributes . A prefix is really just an abbreviation for the namespace identifier (URI), which is typically quite long. The prefix is first mapped to a namespace
identifier through a namespace declaration. The syntax for a namespace declaration is:
xmlns:<prefix>='<namespace identifier>'
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
1. Can a validation requirement such as the one in the following
example be specified in the XML 1.0 schema:
The identification information for a student must include either a
social security number (SSN) or a student id. It is also valid to
specify both.
We were able to specify an exclusive or, that is either A or B, using
the choice group element. A choice group element allows only one of its
children to appear in an instance and thus works for the case of either
SSN or student id.
Can the choice feature be extended to accommodate the inclusive or
case, that is either A or B or both, as stated in the validation
requirement?
If choice cannot be used, is there another schema feature that can be
used to accommodate this case?
2. Is there any way to allow child elements of a group to have a
maxOccurs greater than 1 while at the same time allowing the elements to
occur in any order. The default, sequence, indicates that the
sequence of elements within a group must follow the order indicated in
the schema. The all group allows for flexibility in the order, but
restricts maxOccurs to 0 or 1. Looking at the following example:
<complexType name=description>
<element name=tattoos minOccurs=0 maxOccurs=100>
<element name= birthdate minOccurs=0 maxOccurs=1>
<element name=nicknames minOccurs=0 maxOccurs=10>
</complexType>
We would like to allow multiple occurrences of tattoos and nicknames and
also allow the three elements (tattoos, birthdate, nicknames) to be
specified in any order.
Is it possible to do this in XML Schema 1.0 and, if so, what is the
correct syntax?1. You may use somewhat cumbersome syntax like:
choice
A
B
all
A
B
/all
/choice
to implement inclusive or.
2. They (W3 Schema WG) were talking about
this but decided not to allow it (at least for now). A workaround you may use:
all
group ref = group1
group ref = group2
/all
group name=group1
elem ... maxOccurs = 10
/group
Something like that.
null -
JAXB 1.3 can't parse W3 SOAP 2003-05 envelope XML schema
Hello,
I was trying to use JAXB to parse the MMAP schema from the SMS Forum
(http://www.smsforum.net/schemas/mmap/v1.0/mmap.xsd). I finally
tracked it down to XJC choking on the included SOAP envelope schema's
use of the xml:lang attribute for a tag called reasontext. Here's the
pared-down test case:
C:\java\src\baz>%JWSDP_HOME%\jaxb\bin\xjc.bat http://www.w3.org/2003/05/soap-envelope/soap-envelope.xsd
%JWSDP_HOME%\jaxb\bin\xjc.bat http://www.w3.org/2003/05/soap-envelope/soap-envelope.xsd
parsing a schema...
[ERROR] src-resolve: Cannot resolve the name 'xml:lang' to a(n) attribute declaration component.
line 97 of soap-envelope.xsd
[ERROR] src-ct.0.1: Complex Type Definition Representation Error for type 'reasontext'. Element 'attribute' is invalid, misplaced, or occurs too often.
line 97 of soap-envelope.xsd
Failed to parse a schema.
C:\java\src\baz>I believe that the relevant portions of the schemas and namespaces in
question are:
http://www.w3.org/2003/05/soap-envelope/soap-envelope.xsd
<xs:complexType name="reasontext">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute ref="xml:lang" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>http://www.w3.org/2001/XMLSchema.xsd
<xs:complexType name="attribute" mixed="false">
<xs:complexContent>
<xs:extension base="xs:annotated">
<xs:sequence>
<xs:element name="simpleType" minOccurs="0" type="xs:localSimpleType" />
</xs:sequence>
<xs:attributeGroup ref="xs:defRef" />
<xs:attribute name="type" type="xs:QName" />
<xs:attribute name="use" use="optional" default="optional">
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="prohibited" />
<xs:enumeration value="optional" />
<xs:enumeration value="required" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="default" type="xs:string" />
<xs:attribute name="fixed" type="xs:string" />
<xs:attribute name="form" type="xs:formChoice" />
</xs:extension>
</xs:complexContent>
</xs:complexType>http://www.w3.org/2001/XMLSchema.xsd
<xs:attributeGroup name="defRef">
<xs:annotation>
<xs:documentation>for element, group and attributeGroup, which both define and reference</xs:documentation>
</xs:annotation>
<xs:attribute name="name" type="xs:NCName" />
<xs:attribute name="ref" type="xs:QName" />
</xs:attributeGroup>http://www.w3.org/XML/1998/namespace
The namespace whose name is http://www.w3.org/XML/1998/namespace is
bound by definition to the prefix xml: according to Namespaces in XML,
W3C Recommendation 14 Jan 1999. Note that unlike all other XML
namespaces, both the name and the prefix are specified; i.e., if you
want XML 1.0 processors to recognize this namespace, you must use the
reserved prefix xml:.
xml:lang and xml:space
As of the last update of this document, the XML 1.0 Specification
defines two attribute names in this namespace:
xml:lang
Designed for identifying the human language used in the scope of the
element to which it's attached.
.I'm no XML schema expert, but it looks to me like "name" and "ref"
are both valid attributes for an <xs:attribute> tag and that the XML
namespace standard requires XML processors to recognize the xml:lang
attribute. Hence, this appears to me to be a bug in JAXB.
A secondary bug is that the original error message left the name of
the offending included schema blank:
C:\java\src\foo>d:\java\jwsdp\jwsdp-1.3\jaxb\bin\xjc.bat http://www.smsforum.net/schemas/mmap/v1.0/mmap.xsd
parsing a schema...
[ERROR] src-resolve: Cannot resolve the name 'xml:lang' to a(n) attribute declaration component.
line 97 of
[ERROR] src-ct.0.1: Complex Type Definition Representation Error for type 'reasontext'. Element 'attribute' is invalid, misplaced, or occurs too often.
line 97 of
Failed to parse a schema.
C:\java\src\foo>In case it helps with problem diagnosis, I'm running with J2SDK 1.4.2
and have copied the endorsed jar files into the JRE lib as instructured
with JAXB:
C:\java\src\baz>java -version
java -version
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
C:\java\src\baz>dir %JAVA_HOME%\jre\lib\endorsed
dir %JAVA_HOME%\jre\lib\endorsed
Volume in drive D has no label.
Volume Serial Number is 70AE-6E52
Directory of D:\java\j2se\j2sdk1.4.2\jre\lib\endorsed
03/31/2004 09:41 AM <DIR> .
03/31/2004 09:41 AM <DIR> ..
03/29/2004 01:28 PM 56,619 dom.jar
03/29/2004 01:28 PM 60,963 sax.jar
03/29/2004 01:28 PM 2,823,241 xalan.jar
03/29/2004 01:28 PM 2,667,618 xercesImpl.jar
10/10/2003 06:36 PM 1,379,810 xsltc.jar
6 File(s) 6,989,573 bytes
2 Dir(s) 7,889,731,584 bytes free
C:\java\src\baz>I'm quite interested in the resolution of this issue as I'm stopped in
my tracks on progress here. Help with resolution, whether in JAXB or
my usage of it, will be much appreciated. I did a search of existing
issues but didn't notice a duplicate. Thanks in advance.I have also come across a similar problem with validating an xml file with an xml:lang attribute. It seems to be common across the schema validation and dtd validation. I get the following error with both schema and dtd validation:
Validation Error Msg (0): unexpected attribute "xml:lang"
Validation Error Location (0): FreeFormText
The test file extract looks like this:
<FreeFormText xml:lang="EN">Pelle</FreeFormText>
The schema defines the node as:
<xs:complexType name="FreeFormText">
<xs:simpleContent>
<xs:extension base="FreeFormTextType">
<xs:attribute name="lang" type="xs:language"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
and the dtd defines the node as:
<!ELEMENT FreeFormText
(#PCDATA)>
<!ATTLIST FreeFormText xml:lang CDATA #IMPLIED >
This looks like a bug in JAXB to me aswell. Any help on it would be much appreciated as i am also stuck. -
JAXP API provides no way to enable XML Schema validation mode
I am evaluating XDK 9.2.0.5.0 for Java and have encountered another
problem with XML Schema support when using the JAXP API.
Using the classes in oracle.xml.jaxp.*, it appears to be impossible to
enable XML Schema validation mode. I can set the schema object, but
the parser does not use it for validation.
If I use DOMParser directly, I can call the setValidationMode(int)
method to turn on schema validation mode. There is no equivalient
means to enable XML Schema validation when using the JAXP API.
Test case for JAXP API:
=== begin OracleJAXPSchemaTest.java ======
package dfranklin;
import java.io.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
import oracle.xml.parser.schema.XMLSchema;
import oracle.xml.parser.schema.XSDBuilder;
import org.w3c.dom.*;
import org.xml.sax.*;
public class OracleJAXPSchemaTest
private final static String xsd = ""
+"<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"urn:dfranklin:test\">"
+" <xsd:element name=\"amount\" type=\"xsd:integer\"/>"
+"</xsd:schema>";
private final static String xml =
"<amount xmlns=\"urn:dfranklin:test\">1</amount>";
public static void main(String[] args)
throws Exception
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
"oracle.xml.jaxp.JXDocumentBuilderFactory");
new OracleJAXPSchemaTest().run();
public void run()
throws Exception
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(true);
dbf.setNamespaceAware(true);
XMLSchema xmlSchema = buildXMLSchema(new StringReader(xsd));
dbf.setAttribute("oracle.xml.parser.XMLParser.SchemaObject",
xmlSchema);
DocumentBuilder docbldr = dbf.newDocumentBuilder();
Document doc = docbldr.parse(new InputSource(new StringReader(xml)));
print(doc);
private XMLSchema buildXMLSchema(Reader xsdin)
throws Exception
XSDBuilder xsdBuilder = new XSDBuilder();
XMLSchema xmlSchema = (XMLSchema)xsdBuilder.build(xsdin, null);
return xmlSchema;
private void print(Document doc)
throws
javax.xml.transform.TransformerConfigurationException,
javax.xml.transform.TransformerException
Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.transform(new DOMSource(doc), new StreamResult(System.out));
System.out.println();
=== end OracleJAXPSchemaTest.java ======
Running that program:
java dfranklin.OracleJAXPSchemaTest
produces this output
Exception in thread "main" oracle.xml.parser.v2.XMLParseException: Element 'amount' used but not declared.
at oracle.xml.parser.v2.XMLError.flushErrors(XMLError.java:148)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:269)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:149)
at oracle.xml.jaxp.JXDocumentBuilder.parse(JXDocumentBuilder.java:96)
at dfranklin.OracleJAXPSchemaTest.run(OracleJAXPSchemaTest.java:40)
at dfranklin.OracleJAXPSchemaTest.main(OracleJAXPSchemaTest.java:27)
This shows that the parser is not using the XML Schema to validate the
document. I think it's expecting to find a DTD.
Here is the equivalent program using DOMParser directly, and setting
validation mode to SCHEMA_VALIDATION.
=== begin OracleParserTest.java ====
package dfranklin;
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
import oracle.xml.parser.schema.XMLSchema;
import oracle.xml.parser.schema.XSDBuilder;
import oracle.xml.parser.v2.DOMParser;
import oracle.xml.parser.v2.XMLParser;
import org.w3c.dom.*;
import org.xml.sax.*;
public class OracleParserTest
private final static String xsd = ""
+"<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"urn:dfranklin:test\">"
+" <xsd:element name=\"amount\" type=\"xsd:integer\"/>"
+"</xsd:schema>";
private final static String xml =
"<amount xmlns=\"urn:dfranklin:test\">1</amount>";
public static void main(String[] args)
throws Exception
new OracleParserTest().run();
public void run()
throws Exception
DOMParser dp = new DOMParser();
XMLSchema xmlSchema = buildXMLSchema(new StringReader(xsd));
dp.setXMLSchema(xmlSchema);
dp.setValidationMode(XMLParser.SCHEMA_VALIDATION);
dp.parse(new InputSource(new StringReader(xml)));
Document doc = dp.getDocument();
print(doc);
private XMLSchema buildXMLSchema(Reader xsdin)
throws Exception
XSDBuilder xsdBuilder = new XSDBuilder();
XMLSchema xmlSchema = (XMLSchema)xsdBuilder.build(xsdin, null);
return xmlSchema;
private void print(Document doc)
throws
javax.xml.transform.TransformerConfigurationException,
javax.xml.transform.TransformerException
Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.transform(new DOMSource(doc), new StreamResult(System.out));
System.out.println();
=== end OracleParserTest.java ====
Running that program
java dfranklin.OracleParserTest
produces this output
<?xml version = '1.0'?>
<amount xmlns="urn:dfranklin:test">1</amount>
In this case, the parser has validated the document.
I also tried this with version 10.1.0.0.0 beta, and got the same
error.
Darin FranklinThanks for posting that. I tried that code and still got my problem. The big difference is that I'm reading a group of XML files each of which uses a large number of schema files. There are over 50 schema files organized so they can be included as needed. Each of the XML files has a noNamespaceSchemaLocation attribute specifying one of the ten top schma files, that includes many others.
However, I did solve the problem. I added one line --
saxb.setFeature( "http://apache.org/xml/features/validation/schema",
true);
// next line is new
saxb.setProperty( JAXPConstants.JAXP_SCHEMA_LANGUAGE,
JAXPConstants.W3C_XML_SCHEMA );after the setFeature to turn on schema validation.
(It needs an import org.apache.xerces.jaxp.JAXPConstants; statement.)
Note:With the feature set to true and the setProperty commented out, the EntityResolver is called at construction tiem, and for each schema file, but each element is flagged as needing to be declared.
With the feature commented out, and the setProperty in place, the EntityResolver is not called, and there is no validation performed. (I added invalid content to one of the files and there were no errors listed.)
With both the setFeature and the setProperty in place, however, I get the calls from the EntityResolver indicating that it is processing the schema files, and for the good files, I get no errror, but for the bad file, I get an error indicating a bad validation.
Now I can make the EntityResolver quiet and get what I wanted. Maybe there are other ways to do this, but I've got one that works. :-)
Thanks to all who have helped.
Dave Patterson -
Creating XML Schema from tables With Constraints
Greetings,
I'd have an interesting question. I finally am getting familiar with the various kinds of xml solutions provided by the oracle database, but hey here I have another interesting question I can't seem to get into life. I'm currently generating XML Schemas (XSD) from the tables of my database. Its nice its cool however I'd need to have the table's constraints with the xsd:elements also. And heres my problem, I can't seem to insert the table constrains. I'll show you what I mean:
<xsd:element name="MESSAGE_TABLE">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="MESSAGE_RECORD">
<xsd:complexType>
<xsd:all>
<xsd:element name="ID" type="xsd:integer" minOccurs="1" />
<xsd:element name="HEADER">
<xsd:simpleType>
<xsd:restriction base="xsd:string>
<xsd:maxLength value="255" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<!-- I'd need some more things here like... -->
<!-- Primary key(s) -->
<xsd:key name="PK_ID_PRIM">
<xsd:selector xpath="." />
<xsd:field xpath="ID" />
</xsd:key>
<!-- Foreign key(s) -->
<xsd:keyref name="FK_HEADER_FOREIGN" refer="PK_HEADER_ID">
<xsd:selector xpath="HEADER" />
<xsd:field xpath="ID" />
</xsd:keyref>
<!-- Unique constraint(s) -->
<xsd:unique name="UQ_..." ... />
</xsd:unique>
</xsd:element>That would fit my business needs, however I may be so blind that I can't see the forest from the tree. Currently I got so far that:
xmlElement
"xsd:schema",
xmlAttributes
'http://www.w3.org/2001/XMLSchema' as "xmlns:xsd"
xmlElement
"xsd:element",
xmlAttributes
target_table as "name"
xmlElement
"xsd:complexType",
xmlElement
"xsd:sequence",
xmlElement
"xsd:element",
xmlAttributes
target_table || '_RECORD' as "name",
'unbounded' as "maxOccurs"
xmlElement
"xsd:complexType",
xmlElement
"xsd:sequence",
xmlAgg(ELEMENT)
xmlElement
"xsd:Key",
)As you can see this won't be good since I have put a single xml element in there. I guess I'd need something more like an xmlAgg(CONSTRAINTS), however in that case I'm wondering how will the select's FROM part look like.
FROM
SELECT table_name, internal_column_id,
CASE
WHEN data_type IN ('VARCHAR2', 'CHAR')
THEN
xmlElement
"xsd:element",
xmlattributes
column_name as "name",
decode(NULLABLE, 'Y', 0, 1) as "minOccurs"
xmlElement
"xsd:simpleType",
xmlElement
"xsd:restriction",
xmlAttributes
'xsd:string' as "base"
xmlElement
"xsd:maxLength",
xmlAttributes
DATA_LENGTH as "value"
WHEN data_type = 'DATE'
THEN
xmlElement
"xsd:element",
xmlattributes
column_name as "name",
'xsd:date' as "type",
decode(NULLABLE, 'Y', 0, 1) as "minOccurs"
WHEN data_type = 'NUMBER'
THEN
xmlElement
"xsd:element",
xmlattributes
column_name as "name",
decode(DATA_SCALE, 0, 'xsd:integer', 'xsd:double') as "type",
decode(NULLABLE, 'Y', 0, 1) as "minOccurs"
ELSE
xmlElement
"xsd:element",
xmlattributes
column_name as "name",
'xsd:anySimpleType' as "type",
decode(NULLABLE, 'Y', 0, 1) as "minOccurs"
end ELEMENT
FROM user_tab_cols c
WHERE TABLE_NAME = target_table
ORDER BY internal_column_id
GROUP BY TABLE_NAME;Thank you very much for all your help!
Regards,
Joey
Edited by: Wrath#87 on 2012.09.05. 22:15Thanks for that, answer. That helped me a lot managing primary constraints. However I still have problems managing foreign keys. I come up with the following formula:
xmlElement
"xsd:schema",
xmlAttributes
'http://www.w3.org/2001/XMLSchema' as "xmlns:xsd"
xmlElement
"xsd:element",
xmlAttributes
upper(target_table) as "name"
xmlElement
"xsd:complexType",
xmlElement
"xsd:all",
xmlAgg(ELEMENT)
SELECT xmlElement
"xsd:key",
xmlattributes
uc.constraint_name as "name"
xmlElement
"xsd:selector",
xmlattributes
'.' as "xpath"
xmlAgg
xmlElement
"xsd:field",
xmlattributes
ucc.column_name as "xpath"
order by ucc.position
FROM user_constraints uc
JOIN user_cons_columns ucc
ON ucc.constraint_name = uc.constraint_name
WHERE uc.table_name = upper(target_table)
AND uc.constraint_type = 'P'
GROUP BY uc.constraint_name
SELECT xmlElement
"xsd:keyRef",
xmlattributes
a.constraint_name as "name"
xmlElement
"xsd:selector",
xmlattributes
c.table_name as "xpath"
xmlAgg
xmlElement
"xsd:field",
xmlattributes
d.column_name as "xpath"
order by c.table_name
FROM all_constraints a,
all_cons_columns b,
all_constraints c,
all_cons_columns d
WHERE a.constraint_name = b.constraint_name
AND a.constraint_name = c.r_constraint_name
AND c.constraint_name = d.constraint_name
AND a.table_name = upper(target_table)
)This gives me the following error message: 00937. 00000 - "not a single-group group function" -
Error in Sun XML schema for servlet2.4 deployment descriptor?
Hi,
I'm including the new XML schema for version 2.4 of the servlet standard in my web.xml deployment descriptor, using http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd
When I try to save the XML file, XMLSpy reports an error in the schema file itself: "Undefined schema component 'base' encountered - simpleContext can not have a base that is a complexType with complexContent"
This error is on line 744, and is caused by the snippet:
<xsd:simpleContent>
<xsd:extension base="j2ee:nonEmptyStringType"/>
</xsd:simpleContent>
Can anyone explain why I'm getting a validation failure on this schema? Surely someone else must have experienced the same thing, but I can't track down any reference to it anywhere. Help!XMLSpy is known to be flawed. From my own experience of implementing
validators and data-binding tools, and from my experience of working in the
W3C Schema working group, I can tell you that there are countless cases
where XMLSpy violates the schema specification.
I checked the corresponding part of the schema, but it looks correct to me.
So I suspect that this is another bug in XMLSpy.
Try Xerces. That's probably the best in terms of conformance to the spec. -
Trouble including registered XML Schema in generated XML
Hello,
I'm new to XMLDB, and find myself wanting to build an XML document that conforms
to a paricular XML schema. I'm looking for help in "passing" the shema into the
xml query, and for advice (i may not be going about things in the best way possible).
my data comes from three different sources: deliveries, origin of deliveries (warehouse),
and a user-defined parameter (number of vehicles). I am putting the xml data together via union statements.
this is slightly undesireable due to the limitations on union (no xmltypes, no clobs)
and the size limitation of the varchar datatype. If there is a better way of structuring
the end XML document (all three sources, one output record) then please advise me.
I am having issues "passing" the registered XML schema to the SYS_XMLGEN function,
so if you see where I've made a mistake, please point it out.
Last thing, Oracle version: 9.2.0.4.0 (aka 9iR2)
--Register a new XML schema
--Since this is a GLOBAL schema, register it as privileged user (SYS).
DECLARE
vrp varchar2(10000) :=
'<xs:schema targetNamespace="http://example.com/vrp.xsd"
xmlns:vrp="http://example.com/vrp.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:complexType name="VehicleRoute">
<xs:sequence>
<xs:element name="Stops" type="vrp:Stops" minOccurs="1" maxOccurs="1" />
<xs:element name="Vehicles" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="Warehouse" type="vrp:Warehouse" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Stops">
<xs:sequence>
<xs:element name="Stop" type="vrp:Stop" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Stop">
<xs:sequence>
<xs:element name="Documents" type="vrp:Documents" minOccurs="1" maxOccurs="1" />
<xs:element name="Stop_Address" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="Stop_Minutes" type="xs:double" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Documents">
<xs:sequence>
<xs:element name="Document" type="xs:string" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Warehouse">
<xs:sequence>
<xs:element name="Warehouse_Address" type="xs:string" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:element name="Vehicle_Route" type="vrp:VehicleRoute" />
</xs:schema>';
begin
--"CUSTOM" is the name of my database user - the SCHEMA in which this development should occur.
dbms_xmlschema.registerschema('http://example.com/vrp.xsd', vrp, false, false, false, false, false, 'CUSTOM');
END;Here is the XML schema (as viewed by the 'CUSTOM' user):
<xs:schema targetNamespace="http://example.com/vrp.xsd" xmlns:vrp="http://example.com/vrp.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns:oraxdb="http://xmlns.oracle.com/xdb" oraxdb:flags="17" oraxdb:schemaURL="http://example.com/vrp.xsd" oraxdb:schemaOwner="CUSTOM" oraxdb:numProps="10">
<xs:complexType name="VehicleRoute" oraxdb:SQLType="CLOB">
<xs:sequence>
<xs:element name="Stops" type="vrp:Stops" minOccurs="1" maxOccurs="1" oraxdb:propNumber="2225" oraxdb:global="false" oraxdb:memType="258" oraxdb:SQLInline="true" oraxdb:MemInline="false" oraxdb:JavaInline="false"/>
<xs:element name="Vehicles" type="xs:string" minOccurs="1" maxOccurs="1" oraxdb:propNumber="2226" oraxdb:global="false" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
<xs:element name="Warehouse" type="vrp:Warehouse" minOccurs="1" maxOccurs="1" oraxdb:propNumber="2227" oraxdb:global="false" oraxdb:memType="258" oraxdb:SQLInline="true" oraxdb:MemInline="false" oraxdb:JavaInline="false"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Stops" oraxdb:SQLType="CLOB">
<xs:sequence>
<xs:element name="Stop" type="vrp:Stop" minOccurs="1" maxOccurs="unbounded" oraxdb:propNumber="2228" oraxdb:global="false" oraxdb:memType="258" oraxdb:SQLInline="true" oraxdb:MemInline="false" oraxdb:JavaInline="false"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Stop" oraxdb:SQLType="CLOB">
<xs:sequence>
<xs:element name="Documents" type="vrp:Documents" minOccurs="1" maxOccurs="1" oraxdb:propNumber="2229" oraxdb:global="false" oraxdb:memType="258" oraxdb:SQLInline="true" oraxdb:MemInline="false" oraxdb:JavaInline="false"/>
<xs:element name="Stop_Address" type="xs:string" minOccurs="1" maxOccurs="1" oraxdb:propNumber="2230" oraxdb:global="false" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
<xs:element name="Stop_Minutes" type="xs:double" minOccurs="1" maxOccurs="1" oraxdb:propNumber="2231" oraxdb:global="false" oraxdb:memType="2" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Documents" oraxdb:SQLType="CLOB">
<xs:sequence>
<xs:element name="Document" type="xs:string" minOccurs="1" maxOccurs="unbounded" oraxdb:propNumber="2232" oraxdb:global="false" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Warehouse" oraxdb:SQLType="CLOB">
<xs:sequence>
<xs:element name="Warehouse_Address" type="xs:string" minOccurs="1" maxOccurs="1" oraxdb:propNumber="2233" oraxdb:global="false" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Vehicle_Route" type="vrp:VehicleRoute" oraxdb:propNumber="2224" oraxdb:global="true" oraxdb:SQLType="CLOB" oraxdb:SQLName="Vehicle_Route" oraxdb:memType="258"/>
</xs:schema>Here is sample data for reproducing what I'm seeing:
--Create the "document" table
create table vrp_document
(document_num varchar2(10),
document_minutes number(10),
document_address varchar2(30));
--Sample "document" data
insert into vrp_document (document_num, document_minutes, document_address)
values ('TEST1', 30, '1234 ELM ST');
insert into vrp_document (document_num, document_minutes, document_address)
values ('TEST2', 20, '1234 ELM ST');
insert into vrp_document (document_num, document_minutes, document_address)
values ('TEST3', 40, '1234 MAPLE ST');
insert into vrp_document (document_num, document_minutes, document_address)
values ('TEST3', 15, '1234 YEW ST');
--Create the "warehouse" table
create table vrp_warehouse
(warehouse_id varchar2(3),
warehouse_address varchar2(30));
--Sample "warehouse" data
insert into vrp_warehouse (warehouse_id, warehouse_address)
values ('100', '900 MY OWN WAY');Query to produce XML
Please note, I realize that for the data provided, the aggregations (and sub queries)
are a little over the top. They are however necessary for my actual data set.
SELECT SYS_XMLGEN(xmlagg(XMLTYPE(xmlroute)), xmlformat.createFormat('Vehicle_Route')).getStringVal() Delivery_XML_Data
FROM (SELECT XMLELEMENT("Stops",
XMLAGG(XMLELEMENT("Stop",
XMLCONCAT(
XMLELEMENT("Documents",
xmlagg(xmlelement("Document", t.document))),
xmlforest(t.document_address "Stop_Address",
SUM(t.document_minutes) "Stop_Minutes"))))).getStringVal() AS xmlroute
from (select s.document_num document,
s.document_address,
sum(s.document_minutes) document_minutes
from vrp_document s
group by s.document_num, s.document_address) t
GROUP BY t.document_address
UNION
SELECT XMLELEMENT("Warehouse",
xmlforest(
w.warehouse_address "Warehouse_Address")).getstringval()
from vrp_warehouse w
WHERE w.warehouse_id = '100'
union
select xmlelement("Vehicles", '&Number_Of_Vehicles').getstringval()
FROM dual) g;This query produces the following (Note. Answer "1" or any other integer for &Number_Of_Vehicles):
The only other thing I want is to mention the above schema (that is, xmlns:http://example.com/vrp) or however that goes.
I realize I can "fudge" this by assigning the attribute for various elements, but I think the "right" way would be to modify that call to createFormat().
<?xml version="1.0"?>
<Vehicle_Route>
<Stops>
<Stop>
<Documents>
<Document>TEST1</Document>
<Document>TEST2</Document>
</Documents>
<Stop_Address>1234 ELM ST</Stop_Address>
<Stop_Minutes>50</Stop_Minutes>
</Stop>
<Stop>
<Documents>
<Document>TEST3</Document>
</Documents>
<Stop_Address>1234 MAPLE ST</Stop_Address>
<Stop_Minutes>40</Stop_Minutes>
</Stop>
<Stop>
<Documents>
<Document>TEST3</Document>
</Documents>
<Stop_Address>1234 YEW ST</Stop_Address>
<Stop_Minutes>15</Stop_Minutes>
</Stop>
</Stops>
<Vehicles>1</Vehicles>
<Warehouse>
<Warehouse_Address>900 MY OWN WAY</Warehouse_Address>
</Warehouse>
</Vehicle_Route>I have tried various permutation of the following with no success:
Currently, the error is something serious:
ORA-00600: internal error code, arguments: [kkdotat1], [], [], [], [], [], [], []
00600. 00000 - "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]"
*Cause: This is the generic internal error number for Oracle program
exceptions. This indicates that a process has encountered an
exceptional condition.
*Action: Report as a bug - the first argument is the internal error number
SELECT SYS_XMLGEN(xmlagg(XMLTYPE(xmlroute)), xmlformat.createFormat('Vehicle_Route', 'USE_GIVEN_SCHEMA', 'http://example.com/vrp.xsd', 'http://example.com/vrp.xsd')).getStringVal() Delivery_XML_Data
. . .Edited by: user2316919 on Jan 21, 2010 3:46 PMCannot find a cleanest solution:
SQL> select xmltype('<?xml version="1.0"?>'||
2 xmlelement("Vehicle_Route",
3 xmlattributes('http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi",
4 'http://example.com/vrp.xsd' AS "xsi:schemaLocation"
5 ),
6 xmlagg(xmltype(xmlroute))
7 ).extract('/*')
8 ) Delivery_XML_Data
9 FROM (SELECT XMLELEMENT("Stops",
10 XMLAGG(XMLELEMENT("Stop",
11 XMLCONCAT(
12 XMLELEMENT("Documents",
13 xmlagg(xmlelement("Document", t.document))),
14 xmlforest(t.document_address "Stop_Address",
15 SUM(t.document_minutes) "Stop_Minutes"))))).getStringVal() AS xmlroute
16 from (select s.document_num document,
17 s.document_address,
18 sum(s.document_minutes) document_minutes
19 from vrp_document s
20 group by s.document_num, s.document_address) t
21 GROUP BY t.document_address
22 UNION
23 SELECT XMLELEMENT("Warehouse",
24 xmlforest(
25 w.warehouse_address "Warehouse_Address")).getstringval()
26 from vrp_warehouse w
27 WHERE w.warehouse_id = '100'
28 union
29 select xmlelement("Vehicles", '&Number_Of_Vehicles').getstringval()
30 FROM dual) g;
Immettere un valore per number_of_vehicles: 1
vecchio 29: select xmlelement("Vehicles", '&Number_Of_Vehicles').getstringval()
nuovo 29: select xmlelement("Vehicles", '1').getstringval()
DELIVERY_XML_DATA
<?xml version="1.0"?><Vehicle_Route xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schema
http://example.com/vrp.xsd">
<Stops>
<Stop>
<Documents>
<Document>TEST1</Document>
<Document>TEST2</Document>
</Documents>
<Stop_Address>1234 ELM ST</Stop_Address>
<Stop_Minutes>50</Stop_Minutes>
</Stop>
<Stop>
<Documents>
<Document>TEST3</Document>
</Documents>
<Stop_Address>1234 MAPLE ST</Stop_Address>
<Stop_Minutes>40</Stop_Minutes>
</Stop>
<Stop>
<Documents>
<Document>TEST3</Document>
</Documents>
<Stop_Address>1234 YEW ST</Stop_Address>
<Stop_Minutes>15</Stop_Minutes>
</Stop>
</Stops>
<Vehicles>1</Vehicles>
<Warehouse>
<Warehouse_Address>900 MY OWN WAY</Warehouse_Address>
</Warehouse>
</Vehicle_Route>
{code}
Max
[My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/17/supporto-di-xml-schema-in-oracle-xmldb/]
Maybe you are looking for
-
Error message trying to install new search engines
I am running Firefox 19.0.2 installed yesterday on a new desktop PC at the office. (Old PC failed to boot on Monday.) I have completed most of my customization without difficulty. However, when I try to install new search engines, it doesn't seem to
-
Hello all. I am a newbie at the Mac as of yesterday. I am trying to update my 10.5.7 to 10.5.8 - I figure I should be able to do that via the Software updater. When i click Apple - Software Update, the updater window appears with an error message say
-
I am unable to import raw images into elements 11 camera raw from my panasonic lumix 200
I am unable to import raw files to E11 from my Panasonic Lumix 200. I get a response that says "nothing imported - no supportive file types" also "can't complete request as file appears to be from a camera model which is not supported by installed ve
-
My daughter wants to text and iMessage with her friends using her iTouch. I want to set it up in a way where I can moniter the conversations. Can anyone tell me how to do this? Thank you!
-
I've tried resetting it to the defaults but that didn't help. bp-73f9c4c7-86e9-4bfa-b05a-302772140109 ''(added the crash ID to the thread body - c)''