Simpletype Initial tag in a XML Schema?
Hello,
We have an Oracle 12 EBS implementation, and are using an Advanced Queue dequeue process that can handle a number of XMLType files from different sources as input. The Dequeue procedure right now extracts the value of first field of each of the XML files (which would be a FILETYPE field), and decides which procedure to call. The code used for this is:
v_filetype := message.extract('//FILETYPE/text()').getStringVal();
The procedure called by the de-queue is the one that loads into the XMLType table.
The problem is that I have set up the XML Schema to use a complextype as the first item - and so each different type of XML type would have a different initial tag. For example, suppose there are Purchase Orders and Employees coming through the queue. The Purchase Order Schema file starts like this (example):
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb"
version="1.0"
xdb:storeVarrayAsTable="true">
<xs:element name="PurchaseOrder" type="PurchaseOrderType" xdb:defaultTable="PURCHASEORDER"/>
<xs:complexType name="PurchaseOrderType" xdb:SQLType="PURCHASEORDER_T">
<xs:sequence>
<xs:element name="ORG_ID" type="IdType" minOccurs="0" xdb:SQLName="ORG_ID"/>
and the xml file would be:
<PurchaseOrder xsi:noNamespaceSchemaLocation="PurchaseOrders.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ORG_ID>204</ORG_ID>
... etc.
This system works fine - but the dequeue procedure, which is called before the xml is inserted into the XMLType table does not have a way to determine what kind of XML file this is. So basically, the path will be different for each different type of file.
Is there a easy way to either:
- get the FILETYPE variable some other way using PL/SQL when the initial path would be different for each file type?
- OR define the schema in such a way that allows for that information to be in the same "path"
I was thinking of something along the lines of ...
a) using remarks (how would we be able to read it using simple PL/SQL?)
b) or maybe just defining a simple type as the initial element - kind of like this:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb"
version="1.0"
xdb:storeVarrayAsTable="true">
<xs:element name="FILETYPE" type="String_240Type" xdb:SQLName="FILETYPE"/>
<xs:element name="PurchaseOrder" type="PurchaseOrderType" xdb:defaultTable="PURCHASEORDER"/>
<xs:complexType name="PurchaseOrderType" xdb:SQLType="PURCHASEORDER_T">
<xs:sequence>
<xs:element name="ORG_ID" type="IdType" minOccurs="0" xdb:SQLName="ORG_ID"/>
with a corresponding xml of:
<FILETYPE xsi:noNamespaceSchemaLocation="PurchaseOrders.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">PO</FILETYPE>
<PurchaseOrder>
<ORG_ID>204</ORG_ID>
(but XMLSpy assures me this is not valid - neither the xchema nor the xml)
Any help would be deeply appreciated!
Thanks!
Edited by: user11313400 on Aug 17, 2009 11:17 AM
Edited by: user11313400 on Aug 17, 2009 11:20 AM
I don't fully understand all the issues behind your questions but I'll give some answers. What is wrong with your current code of
v_filetype := message.extract('//FILETYPE/text()').getStringVal();in retrieving the FILETYPE? While the use of // is not the best for performance, that will find FILETYPE where ever it resides in the message XML? If you know FILETYPE resides at a certain level, you could also do the following to improve performance a bit (untested theory)
v_filetype := message.extract('/*/FILETYPE/text()').getStringVal();
That sample assumes FILETYPE is a child of the root node, and doesn't care what the root node is named.
As you are going to, the best method would be to have FILETYPE is the same location for all the XML messages to make retrieval the easiest. Without a larger sample of your .xsd I won't offer a working solution, but can you just make FILETYPE part of the PurchaseOrderType definition? I know you mentioned multiple XML file types so I'm not sure what the others look like and what you can and cannot change.
Other thoughts:
- Could you pass in the file type as part of what is enqueued in AQ?
- Can you determine file type from the name of the root node in the XML?
Similar Messages
-
Hi,
I have created a local varibale and stored my xml schema (xml structure) in it. I am using a sql query to fetch the records from databae and populating it to the schema using Assignment action block. But I have a requirement that one of the tag in the xml schema should be added dynamicaly according to the result of the query. Can anyone help me on this? . In the Linktype I saw one option as Append xml. How can we use that option
Please let me know if you have any thoughts on this
Thanks in advance
ShajiHi Shaji,
Please find the below link: It explains all the XML functions in MII Workbench.
http://wbhelp.sap.com/manufacturing/xmii_120/en/44/7ca00d32406572e10000000a11466f/content.htm
"Calculated Columns" can be useful here as per your requirements.
For help on Link Types, go through the following link:
http://wbhelp.sap.com/manufacturing/xmii_120/en/44/89aa7088cc6fb5e10000000a155369/content.htm
Hope this will help you.
Best regards,
Kedar -
XML Schema Generated By XMLSpy fails validation in JDev 10.1.3.0.4
Hi gurus,
I am trying to view an XML schema generated by XMLSpy in JDev 10.1.3.0.4 but got this error:
Error(6,74): <Line 6, Column 74>: XML-24523: (Error) Invalid value 'simpletypes\AmendmentReasonChargeType.xsd' for attribute: 'schemaLocation'
Now in the XML schema, there is this line that causes the above error:
<xs:include schemaLocation="simpletypes\AmendmentReasonChargeType.xsd"/>
The same XML schema can be opened in Visual Studio 2003 OK. Could anyone help me out here? Thank you!
BenThere is a tool tip that displays over the line that causes the error and this is what it says,
value of attribute schemaLocation not of anyURI type. The value must be of the following type:
Type Name: anyURI Primitive Type: anyURI
What does it mean?
Thanks
Ben -
Not able to pass cyclic XML schema type to a webservice method
I have a webservice method called getData(GetDataDocument
gDoc).
I constructed a request with object (which exactly satisfy
the XML schema def) to call up the getData(). [From my java client
also I did the same; but the java classes have been generated using
apache's xmlBeans; this works fine with the same kind of request].
But the soap request constructed from flex does not get
generated with all the values that I set in the request object.
On further observation, I found out that if the schema
involves cyclic elements, the soap request is not getting
constructed as desired.
My schema def:
<complexType name="PredicateBagType">
<sequence>
<choice>
<element maxOccurs="unbounded" minOccurs="0"
name="PredicateBag" type="tns:PredicateBagType"/>
<element maxOccurs="unbounded" minOccurs="0"
name="BinaryPredicate" type="tns:BinaryPredicateType"/>
<element maxOccurs="unbounded" minOccurs="0"
name="UnaryPredicate" type="tns:UnaryPredicateType"/>
</choice>
</sequence>
<attribute name="contextNode"
type="tns:contextNodeIDType"/>
<attribute default="false" name="negate"
type="boolean"/>
<attribute name="type"
type="tns:PredicateBagTypeType"/>
</complexType>
Note that the PredicateBagType may contain another
PredicateBagType.
I have constructed my request with objects in my flex
application . Though I have set the BinaryPredicate object in my
PredicateBag object, the soap request constructed looks like this
which is not desired
<SOAP-ENV:Envelope xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<tns:get_Data maxPrograms="0" personalInfoUse="false"
xmlns:tns="urn:tva:transport:2005">
<tns:QueryConstraints>
<tns:PredicateBag contextNode="1" negate="false"
type="AND"/>
</tns:QueryConstraints>
<tns:RequestedTables>
<tns:Table type="ProgramInformationTable"/>
</tns:RequestedTables>
</tns:get_Data>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>.
If I comment out the PredicateBagType choice in my xsd, the
flex application constructs the soap request looks like this.
<SOAP-ENV:Envelope xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<tns:get_Data maxPrograms="0" personalInfoUse="false"
xmlns:tns="urn:tva:transport:2005">
<tns:QueryConstraints>
<tns:PredicateBag contextNode="ProgramInformation"
negate="false" type="AND">
<tns:BinaryPredicate fieldID="Genre" fieldValue="Fiction"
test="contains"/>
</tns:PredicateBag>
</tns:QueryConstraints>
<tns:RequestedTables>
<tns:Table type="ProgramInformationTable"/>
</tns:RequestedTables>
</tns:get_Data>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This request holds good. But I cannot comment out the
PredicateBagType from my choice. Is this an issue with soap request
construction issue in Flex..?Yes, <choice> is just "partial" supported in Flex 2 .
read this
link
for partial and not supported tags
Partially supported XML Schema structures
The following XML Schema structures or structure attributes
are only partially implemented in this release:
<choice>
<all>
<union>
regards
kcell -
Length of enumerations in xml-schema always 4000?
Hi, I have a question regarding enumerations in a xml-schema.
All simpletypes containing enumerations in my xml-schema are created with a length of 4000 instead of the specified length:
eg: <xs:simpleType name="YesNo">
<xs:restriction base="xs:string">
<xs:minLength value="2"/>
<xs:maxLength value="3"/>
<xs:enumeration value="Yes"/>
<xs:enumeration value="No"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="Radio" type="YesNo" fixed="Yes" xdb:SQLName="RADIO_IND" xdb:SQLType="VARCHAR2">
</xs:element>
the element Radio is created as VARCHAR2(4000) instead of VARCHAR(3), if I remove the enumerations it is created correctly!
Any suggestions?
Thx!
Bart HoubenI'm using 9.2.0.3.0 (on Win 2000 Server).
Can you test the following schema?
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:simpleType name="YesNo">
<xs:annotation>
<xs:documentation>Data type that contains a boolean Yes or No.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:minLength value="2"/>
<xs:maxLength value="3"/>
<xs:enumeration value="Yes"/>
<xs:enumeration value="No"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="ROOT" xdb:SQLType="ROOT_TYPE" xdb:defaultTable="ROOT">
<xs:annotation>
<xs:documentation>This is the root element.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="TEST" type="YesNo" xdb:SQLName="TEST_IND" xdb:SQLType="VARCHAR2">
<xs:annotation>
<xs:documentation>element </xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
This is how I register the schema:
begin
dbms_xmlschema.registerSchema
'TEST.xsd',
xdbURIType('/home/Schema/TEST.xsd').getClob(),
True,True,False,True
End;
SQL> desc root_type
root_type is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
TEST_IND VARCHAR2(4000)
As you see I get a VARCHAR2(4000) for test_ind.
Thank you very much for your help! -
How to handle include tag in xml schema
My XML schema makes reference to other schema, something like:
<xsd:include schemaLocation="../LOCCommon/LOCCommon.xsd"/>
How do I handle this when using XML DB?XDB does currently understand relative URLs. We are looking at this since thier use is becoming more common. You will need to register both schemas under absolute URLs and then adjust the URL of the include or import statement to reflect this...
The following code sample may help...
procedure fixRelativeURLs(xmlschema in out xmltype, schemaLocationHint varchar2)
as
cursor getImports is
select SCHEMA_LOCATION
from xmlTable
xmlnamespaces
default 'http://www.w3.org/2001/XMLSchema'
'/schema/import'
passing xmlSchema
columns
SCHEMA_LOCATION varchar2(700) path '@schemaLocation'
cursor getIncludes is
select SCHEMA_LOCATION
from xmlTable
xmlnamespaces
default 'http://www.w3.org/2001/XMLSchema'
'/schema/include'
passing xmlSchema
columns
SCHEMA_LOCATION varchar2(700) path '@schemaLocation'
baseURL varchar2(700);
schemaLocation varchar2(700);
targetURL varchar2(700);
begin
if instr(schemaLocationHint,'/',-1) > 0 then
baseURL := substr(schemaLocationHint,1,instr(schemaLocationHint,'/',-1)-1);
else
baseURL := '/';
end if;
for import in getImports loop
targetURL := baseURL;
schemaLocation := import.SCHEMA_LOCATION;
-- The following are treated as relative URLs
-- URLs with no '/' character
-- URLs which do not start with '/' and which do not contain '://'
if ((instr(schemaLocation,'://') = 0) and (instr(schemaLocation,'/') <> 1)) then
if (instr(schemaLocation,'..') = 1 ) then
while instr(schemaLocation,'..') = 1 loop
schemaLocation := substr(schemaLocation,4);
targetURL := substr(targetURL,1,instr(targetURL,'/',-1)-1);
end loop;
end if;
schemaLocation := targetURL || '/' || schemaLocation;
-- dbms_output.put_line('Import : re-mapping "' || import.SCHEMA_LOCATION || '" to "' || schemaLocation || '".');
select updateXML
xmlSchema,
'/xsd:schema/xsd:import[@schemaLocation="' || import.SCHEMA_LOCATION || '"]/@schemaLocation',
schemaLocation,
NAMESPACES
into xmlSchema
from dual;
else
dbms_output.put_line('Import : skipping "' || import.SCHEMA_LOCATION || '".');
end if;
end loop;
for include in getIncludes loop
targetURL := baseURL;
schemaLocation := include.SCHEMA_LOCATION;
-- The following are treated as relative URLs
-- URLs with no '/' character
-- URLs which do not start with '/' and which do not contain '://'
if ((instr(schemaLocation,'://') = 0) and (instr(schemaLocation,'/') <> 1)) then
if (instr(schemaLocation,'..') = 1 ) then
while instr(schemaLocation,'..') = 1 loop
schemaLocation := substr(schemaLocation,4);
targetURL := substr(targetURL,1,instr(targetURL,'/',-1)-1);
end loop;
end if;
schemaLocation := targetURL || '/' || schemaLocation;
-- dbms_output.put_line('Include : re-mapping "' || include.SCHEMA_LOCATION || '" to "' || schemaLocation || '".');
select updateXML
xmlSchema,
'/xsd:schema/xsd:include[@schemaLocation="' || include.SCHEMA_LOCATION || '"]/@schemaLocation',
schemaLocation,
NAMESPACES
into xmlSchema
from dual;
else
dbms_output.put_line('Inlcude : skipping "' || include.SCHEMA_LOCATION || '".');
end if;
end loop;
end;
-- -
Sorry for this post, because it really isn't a weblogic specific thing, but I can't
find my answer
anywhere else.
I am attempting to validate my xml file using an XML Schema file. The XML
Schema code looks like this:
<xsd:element name="operatingSystem">
<xsd:simpleType>
<xsd:list>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value=".*(w|W)(I|i)(n|N).*"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:list>
</xsd:simpleType>
</xsd:element>
The XML snippet looks like this:
<operatingSystem>Windows 2000</operatingSystem>
The error that I'm getting when using the SaxParser is the following:
org.xml.sax.SAXException: cvc-pattern-valid: Value '2000' is not facet-v
alid with respect to pattern '.*(w|W)(I|i)(n|N).*' for type 'null'.
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at SAXLocalNameCount.main(SAXLocalNameCount.java:272)
Somehow, the validation breaks my one string in the operatingSystem tag into
two separate strings to be validated. Can anybody give me some advice on
what to do?
Thanks in advance,
Joelfor some reason it does not like a space between "Windows" and "2000" any
character other than space is fine...
"Joel" <[email protected]> wrote in message
news:3fa9468b$[email protected]..
>
Sorry for this post, because it really isn't a weblogic specific thing,but I can't
find my answer
anywhere else.
I am attempting to validate my xml file using an XML Schema file. The XML
Schema code looks like this:
<xsd:element name="operatingSystem">
<xsd:simpleType>
<xsd:list>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value=".*(w|W)(I|i)(n|N).*"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:list>
</xsd:simpleType>
</xsd:element>
The XML snippet looks like this:
<operatingSystem>Windows 2000</operatingSystem>
The error that I'm getting when using the SaxParser is the following:
org.xml.sax.SAXException: cvc-pattern-valid: Value '2000' is not facet-v
alid with respect to pattern '.*(w|W)(I|i)(n|N).*' for type 'null'.
at org.apache.xerces.parsers.AbstractSAXParser.parse(UnknownSource)
at SAXLocalNameCount.main(SAXLocalNameCount.java:272)
Somehow, the validation breaks my one string in the operatingSystem taginto
two separate strings to be validated. Can anybody give me some advice on
what to do?
Thanks in advance,
Joel -
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. -
I'm having a brutal time working with this program, it doesn't even seem like it should be this hard. I won't get in to the situation yet, I keep tripping across other problems as I go. Here's the next one:
According to Eclipse, I'm not allowed to put an element with a type if it also has a restriction, because the restriction seems to (as far as I can tell) automatially attach an "anonymous type" to the element. That is to say:
<element name="foo" type="string">
<simpleType>
<restriction base="string">
[restriction tags]
</restriction>
</simpleType>
</element>doesn't work. It also doesn't work if I don't have a "base='x'" line, but that makes a bit more sense. On the other hand:
<element name="foo">
<simpleType>
<restriction base="string">
[restriction tags]
</restriction>
</simpleType>
</element>
does work, but causes a number of problems because "foo" no longer has a type to call its own. I'm sure I'm missing something here but I can't work out what.
Here's the exact error from Eclipse's XML Schema Validator, which places an error on foo's declaration line:
"Multiple Annotations found on this line:
- src-element.3: Element 'foo' has both a 'type' attribute and a 'anonymous type' child. Only one of these is allowed for an element.
- Element type "element" must either be followed by attribute types, '>' or '/>'."
Any help would be appreciated, thanks. :)As the message below indicates you are defining a new simple type but in line with the element definition (enclosed by element tags). As it is in-line it is classed as an anonymous type i.e. has no name. You therefore cannot give an element a type and then specify its type in line.
Athough essentially it is a string (hence requires base type) it is nontheless a new type i.e a string with restrictions. The other way to do this, which will allow you to reuse the type is is as follows
<xsd:element name="foo" type="myRestrictedString"/>
<xsd:element name="foo2" type="myRestrictedString"/>
<xsd:simpleType name="myRestrictedString">
<xsd:restriction base="xsd:string">
<xsd:pattern value="[0-9]{3}"/>
</xsd:restriction>
</xsd:simpleType>
>
"Multiple Annotations found on this line:
- src-element.3: Element 'foo' has both a 'type'
attribute and a 'anonymous type' child. Only one of
these is allowed for an element.
- Element type "element" must either be followed by
attribute types, '>' or '/>'." -
Validate XML against Xml Schema using JDBC (thin_driver)
hi all,
i have a table with a xmltype-column (XmlSchema Support) and i wonna load(and validate) xml-data( as String) in the xmltype-column.
some thing like this :
int count=1;
String SQLTEXT=null;
Statement stmt=null;
ResultSet rs =null;
//while(count<=1000)
try
stmt = connection.createStatement();
rs = stmt.executeQuery("select SEQ_patxmlschema_ID.NEXTVAL from patxmlschema");
if(rs.next())
id =rs.getLong(1);
System.out.println(id);
stmt.close();
stmt=null;
rs.close();
SQLTEXT = "INSERT INTO patxmlschema(id, patID, name, status, patInfo)"+
"VALUES(?,?,?,?,XMLType(?))";
pStmt = connection.prepareStatement(SQLTEXT);
long patID = random.nextInt(30000);
System.out.println("patId: "+ patID);
String name = RandomStringUtils.random(6,true,false);
System.out.println("lastname: "+ name);
String firstname=RandomStringUtils.random(5,true,false);
System.out.println("firstname: "+ firstname);
String status=RandomStringUtils.random(8,true,false);
System.out.println("status: "+ status);
String street=RandomStringUtils.random(6,true,false);
System.out.println("street: "+ street);
String zip=RandomStringUtils.random(5,false,true);
System.out.println("zip: "+ zip);
String city=RandomStringUtils.random(6,true,false);
System.out.println("city: "+ city);
String phone=RandomStringUtils.random(8,false,true);
String email=RandomStringUtils.random(15,true,false);
String state=RandomStringUtils.random(6,true,false);
String country=RandomStringUtils.random(6,true,false);
System.out.println("country: "+ country);
xmldoc=
"<Patient>"+ "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+ "xsi:noNamespaceSchemaLocation='http://olidong.net/patInfo.xsd'>"+
"<Address>"+ "<street>"+street+"</street>"+ "<city>"+city+"</city>"+ "<zip>"+zip+"</zip>"+
"<state>"+state+"</state>"+ "<country>"+country+"</country>"+
"</Address>"+ "<phone>"+phone+"</phone>"+ "<email>"+email+"</email>"+
"</Patient>";
pStmt.setLong(1, id);
pStmt.setLong(2, patID);
pStmt.setString(3, name);
pStmt.setString(4, status);
pStmt.setString(5, xmldoc);
pStmt.executeUpdate();
pStmt.close();
pStmt=null;
count++;
//connection=null;
catch(Exception e){
e.printStackTrace();
can you help me?
Olidonghi Avi,
my xml doc is valid. with the sqlplus the are no problem or error. tryng the same with jddbc(thin driver) i got this error.
i don´t know, may be jdbc don´t support xml schema support insertion.
i got this sample:
DECLARE
doc VARCHAR2(2000) :=
'<schema
targetNamespace="http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd"
xmlns:po="http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<complexType name="PurchaseOrderType">
<sequence>
<element name="PONum" type="decimal"/>
<element name="Company">
<simpleType>
<restriction base="string">
<maxLength value="100"/>
</restriction>
</simpleType>
</element>
<element name="Item" maxOccurs="1000">
<complexType>
<sequence>
<element name="Part">
<simpleType>
<restriction base="string">
<maxLength value="20"/>
</restriction>
</simpleType>
</element>
<element name="Price" type="float"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
<element name="PurchaseOrder" type="po:PurchaseOrderType"/>
</schema>';
BEGIN
DBMS_XMLSCHEMA.registerSchema(
'http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd', doc);
END;
CREATE TABLE mypurchaseorders OF XMLType
XMLSchema "http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd"
ELEMENT "PurchaseOrder"
VARRAY xmldata."Item" STORE AS TABLE item_nested;
INSERT INTO mypurchaseorders
VALUES(
XMLType(
'<PurchaseOrder
xmlns="http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation
= "http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd
http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd">
<PONum>1001</PONum>
<Company>IBM</Company>
<Item>
<Part>DB2 v9 Set</Part>
<Price>2550</Price>
</Item>
<Item>
<Part>8i Doc Set</Part>
<Price>350</Price>
</Item>
</PurchaseOrder>'));
with the sqlplus the are no error
but insert with java jdbc:
SQLTEXT = "INSERT INTO mypurchaseorders VALUES(XMLType(?))";
String xmldoc= "<PurchaseOrder"+
"xmlns='http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd'" +
"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
"xsi:schemaLocation= 'http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd'"+
"'http://xmlns.oracle.com/xdb/documentation/purchaseOrder.xsd'>"+
"<PONum>1001</PONum>"+
"<Company>IBM</Company>"+
"<Item> "+
"<Part>DB2 v9 Set</Part>"+
"<Price>2550</Price>"+
"</Item>"+
"<Item>"+
"<Part>8i Doc Set</Part>"+
"<Price>350</Price>"+
"</Item>"+
"</PurchaseOrder>";
pStmt.setString(1, xmldoc);
i got this error
java.sql.SQLException: ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00240: element-start tag is not well formed
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 301
ORA-06512: at line 1
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:952)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1160)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
at xml_tab.doInsert(xml_tab.java:118)
at xml_tab.main(xml_tab.java:138)
could you help me?
Olidong -
Hi,
I am finding a problem with the XML schema that oracle-XSU
generates.
I try to open it in a standard XML IDE like XML spy and it gives
me a error on
following 2 counts
1. It says the schema doesn't confirm to XML schema standard as
it does not
start with xsu:schema tag
2. After I modify the initial tag to xsu:schema, it says that
the schema is not
conforming to the latest W3C standards and gives me an option to
modify
the schema to the latest standard.
How do we go about resolving such issues?The component palette is not sensitive to selection and only contains palette items for globally defined elements (without writing a JDeveloper Extension anyway). The structure pane context menus and code insight show all possible elements that could be inserted at a particular location.
We are considering ways of showing locally defined elements in an enhanced
component palette design in a future JDeveloper release. -
Simple content pattern in XML Schema
Hi,
I have a big problem with xml Schema. I have to design an xml schema entry which allows me to enter a tag like <tag>{time}.{date}- </tag> in the xml file. I can enter any text in between the <tag>. But the problem is if I enter the "{" in between the tag it should end with "time}" or "date}" only.
Please help me in doing this.
Thanks,
KrishnaAdd a simpleType with pattern restriction:
<xs:element name="A">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value=""/>
</xs:simpleType>
</xs:element -
XML Schema -- xsi:null in document instance and nullable in XSD
Hi,
I have an XML document
<DOC>
<EMP_ID>1</EMP_ID>
<EMP_NAME>Scott</EMP_NAME>
<EMP_ADDRESS>USA</EMP_ADDRESS>
</DOC>
As to what I understand, for the document to look like
<DOC>
<EMP_ID>1</EMP_ID>
<EMP_NAME>Scott</EMP_NAME>
<EMP_ADDRESS></EMP_ADDRESS>
</DOC>
with no value in <EMP_ADDRESS> tag, I have to use nullable attribute in XSD and xsi:null attribute in document. Is there any other way where we don't make any modificaitons in the documentHi, Thanks for the reply.I have a scenario like this :
1. We have lot of xml files in our application server ( size ranges form 2 MB to 200 MB).
2. We have xml schema based structured storage for a column "personjoininfo" for a relational table --- Table is :
CREATE TABLE PERSON_COMP_TABLE
empId VARCHAR2(100) CONSTRAINT pk_PERSONCOMP PRIMARY KEY
,comments VARCHAR2(20)
,joindate DATE
,personjoininfo xmltype
XMLTYPE COLUMN personjoininfo XMLSCHEMA "www.PersonInfoUrl.com" element "person"
3. What is the best option for me to load the xml files in the personjoin info column along with the other column values.
As I know , if I use the XML DIR ( directory feature ), I would need to put these xml files in the database server for loading ---
So, what are my options in this scenario for loading these xml files ?
Thanks -
XML Schema validator fails to load XML Schema from URL
I'm trying to validate an XML document against a set of XML Schemas and the parser seems to freak out: even though all the schemas are referred to in the XML and are properly recognized by Schemas field in XML document properties, I get warnings (multiple
instances):
Request for the permission of type 'System.Net.WebPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed
Cannot resolve the 'schemaLocation' attribute
The schema referenced from this location in your document contains errors
The warning locations are also seemingly random - errors in schema locations are reported on closing tags inside XML or on whitespaces, and so on.
The first warning (System.Net.WebPermission) suggests it has something to do with access to remote schemas, but all the necessary remote schemas are visible in XML Schema Set editor for the document. I also enabled downloading of XML schemas in XML text
editor options.Hi Tomasz,
Thank you for posting in MSDN forum.
Since this issue is related to the XML Schemas, so we will move this case to the XML forum:https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=xmlandnetfx
, you will get better support.
Best Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Unable to locate Spring NamespaceHandler for XML schema namespace
I am not sure if this is the best practice approach but this is the problem I am ruining into. Below, I explain what I am doing:
1) What I am doing:
=============
Based on the oracle incubator example (http://coherence.oracle.com/display/INCUBATOR/Processing+Pattern+Examples); I am running a server and submitting tasks through a proxy application that submits them to ProcessingPatternConfigurator; let's call my task processReport.
a) my processReport is using spring and ibatis together, I created a utility static class to obtain a spring context and retrieves beans using the following lines ( see exhibit "A1 and A2" below).
b) when my task calls the context and that spring loads, it is failing with the error show in exhibit "B".
I suspect I am missing a lib? I googled the error and searched you site but could find a meaningful discussion on it. I guess my question is if this is not the best approach, how do I integrated with spring initializing beans and setting up ibatis framwork, providing beans and database access through Ibatis for each task ruining on the grid (processReport).
thanks
A1) processReport (submitted in the grid) uses this line
AbstractXmlApplicationContext ctx = (AbstractXmlApplicationContext) AmrContextUtil.getInstance();
System.out.println("Classpath loaded. Executing Report...");
ReportProcessor repProcessor = (ReportProcessor) ctx.getBean("reportProcessor");
A2) Here is the AmrContextUtil:
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public final class AmrContextUtil {
private static AbstractApplicationContext ctx = null;
public AmrContextUtil() {
super();
public final static synchronized AbstractApplicationContext getInstance(){
if (ctx == null){
ctx = new ClassPathXmlApplicationContext("classpath:config/applicationContext.xml");
setCtx(ctx);
return ctx;
public final static synchronized AbstractApplicationContext getCtx() {
return ctx;
public final static synchronized void setCtx(AbstractApplicationContext ctx) {
AmrContextUtil.ctx = ctx;
B) Here is the error reported by the server:
2010-02-10 15:42:28.312/57.986 Oracle Coherence GE 3.5.2/463 <Warning> (thread=GridExecutor:Thread-2
, member=1): TaskRunner - Failed to process 0x00000126B99E5524AC1F007AAB1587BBCFEC5E6637E1DED6CCB984
03D6AADF4D due to:org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:config/reports-application.xml] Offending resource: class path resource [config/applicationContext.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unexpected failure during bean definition parsing
Offending resource: class path resource [config/reports-application.xml] Bean 'reportSqlMapConfig'; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: *Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/util]*
*Offending resource: class path resource [config/reports-application.xml] Bean 'reportSqlMapConfig'*
-> Property 'resourceMap'
c)Here is my application-context.xml offending line:
<bean id="reportSqlMapConfig"
class="com.xx.report.generator.ReportSqlMapConfig">
<property name="resourceMap">
<map>
<entry>
<key>
<util:constant static-field="com.xx.report.domain.ReportType.FPA"/>
</key>
<value>classpath:config/diehardReportSqlMapConfig.xml</value>
</entry>
<entry>
<key>
<util:constant static-field="com.xx.report.domain.ReportType.FCN"/>
</key>
<value>classpath:config/falconReportSqlMapConfig.xml</value>
</entry>
<entry>
<key>
<util:constant static-field="com.xx.report.domain.ReportType.ODS"/>
</key>
<value>classpath:config/odsReportSqlMapConfig.xml</value>
</entry>
</map>
</property>
</bean>My guess is that something is broken in the configuration of the cacheServer and its not finding
all of the dependencies that your process pattern application needs. Probably the best way
to debug this stuff is to define a static main in your runnable task which will make the call
to the run() method and invoke it as the main class using the identical settings (classpath,
run directory) that you are using to launch the Coherence cache server.
Regards,
Bob
Maybe you are looking for
-
After Itunes upgraded to latest version 11.0.2.26 Apple TV (1st gen) does not show up anywhere in Itunes
-
I have a new computer and after I downloaded iTunes my music library is empty. I had to deauthorize my last computers since I was at the 5 limit. How do I get my music?
-
Infotype for Personnel Email Address
Hi, What is the Infotype to maintain the Personnel Email Address? I have an Interface Updating Employee Vendor Master Records from the HR Master Records but it is not updating the Email Address. Can you please suggest me what should be done to make t
-
Mac OS Tiger (10.4.10) disconnected from Epson Stylus DX 6050?
My Mac Mini OS X cannot find my Epson Stylus DX 6050, after a year of trouble- free printing. I've tried uninstalling, reinstalling, downloading driver from Epson website, but it's no good I can't connect. USB connections appear OK. I can really do w
-
Same problem like Pavol Medved
I was trying to do my first Jdev 3.1.1.2 tutorial and on page 5 of 10 of section 'Launching the Business Components Data Form Wizard':Database Objects I can't see any objects. I tried to create Associations and ViewLinks but then I just got the DeptV