Read XML with different schema definitions
Hello,
I have an XML stored in a table as XMLTYPE and I have no problem to read the first part (ELMAHeader)
WITH t AS(
SELECT XMLTYPE(
q'[<?xml version = '1.0' encoding = 'UTF-8'?>
<ELMAKM xsi:noNamespaceSchemaLocation="./KM/01.00/ELMAKM_000001.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:km="http://www.zivit.de/KiStA/KiStAM/V1.0/KiStA-KiStAM-Anfrage">
<ELMAKOM>
<ELMAHeader ELMAKMVersion="1">
<AuthSteuernummer>BG</AuthSteuernummer>
<AccountID>11</AccountID>
<KundeneigeneID>1</KundeneigeneID>
<Verarbeitungslauf>PROD</Verarbeitungslauf>
<ErstellungsDatum>2014-09-16</ErstellungsDatum>
<ErstellungsZeit>11:00:27.7</ErstellungsZeit>
</ELMAHeader>
<ELMAVerfahren>
<KISTA_KM_ANTW UUID="0345" OrdBegriff="SLD"
xsi:schemaLocation="http://www.zivit.de/KiStA/KM/01.00-r000001 ./KM/01.00/ELMAKM_KISTA_000001.xsd"
xmlns="http://www.zivit.de/KiStA/KM/01.00-r000001"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:k="http://www.zivit.de/KiStA/Std/01.00-r000001">
<KiStAV_DL Zulassungsnummer="2"/>
<KiStAV Zulassungsnummer="2" Name="SLD"/>
<Antwort xsi:type="AntwortArt3" UUID="0f" KdOrdBegriff="4">
<ReturnCode>1</ReturnCode>
<Anlass Datum="2014-08-11" Grund="1"/>
<PersAngabe>
<Person>
<k:NName>B</k:NName>
<k:VName>Y</k:VName>
<k:GebDt>1944-10-11</k:GebDt>
</Person>
<Adresse xsi:type="k:InlandsAdresse">
<k:Str>A-Str.</k:Str>
<k:HausNr>5</k:HausNr>
<k:Ort>M</k:Ort>
<k:Plz>8</k:Plz>
</Adresse>
</PersAngabe>
</Antwort>
</KISTA_KM_ANTW>
</ELMAVerfahren>
</ELMAKOM>
</ELMAKM>]') x FROM dual
SELECT x
,elma.ELMAKMVersion
,elma.AuthSteuernummer
,elma.AccountID
,elma.KundeneigeneID
FROM t
,XMLTABLE(
'/ELMAKM/ELMAKOM/ELMAHeader'
PASSING t.x
COLUMNS ELMAKMVersion VARCHAR2(8) PATH '@ELMAKMVersion'
,AuthSteuernummer VARCHAR2(10) PATH 'AuthSteuernummer'
,AccountID VARCHAR2(10) PATH 'AccountID'
,KundeneigeneID VARCHAR2(10) PATH 'KundeneigeneID'
) elma
But how can I read the second part(ELMAVerfahren)? I tried many selects but I get no results, e.g.
WITH ...
SELECT x
,elma.UUID
FROM t
,XMLTABLE(
XMLNAMESPACES(
DEFAULT './KM/01.00/ELMAKM_KISTA_000001.xsd'
,'http://www.zivit.de/KiStA/KiStAM/V1.0/KiStA-KiStAM-Anfrage' AS "km"
,'http://www.zivit.de/KiStA/Std/01.00-r000001' AS "k"
'/ELMAKM/ELMAKOM/ELMAVerfahren/KISTA_KM_ANTW'
PASSING t.x
COLUMNS UUID VARCHAR2(8) PATH '@UUID'
) elma
DB version
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
Regards
Marcus
Hi Marcus,
If you declare a default namespace using the XMLNamespaces clause, it'll apply to all unqualified elements referenced by the XQuery expression.
In your attempt, ELMAKM, ELMAKOM and ELMAVerfahren are treated as being part of the default namespace, which is wrong since those nodes are in no namespace.
To handle this kind of situations, where there are default namespace redefinitions down the tree, you have to declare a prefix :
SELECT x
,elma.UUID
FROM t
,XMLTABLE(
XMLNamespaces('http://www.zivit.de/KiStA/KM/01.00-r000001' as "ns0")
, '/ELMAKM/ELMAKOM/ELMAVerfahren/ns0:KISTA_KM_ANTW'
PASSING t.x
COLUMNS UUID VARCHAR2(8) PATH '@UUID'
) elma
Similar Messages
-
It's possible reads in a same e-reader, books with different Adobe ID
it's possible reads in a same e-reader, books with different Adobe ID
i think is possible but ONLY in the same jar.
If i try to use different jar i get only the instance of class that the classloader load.....
any suggestion? -
How to read data with different XML schemas within the single connection?
I have Oracle 11g database
I access it through jdbc:oracle:thin, version 11.2.0.3, same as xdb.
I have several tables, each has one XMLType column, all schema-based.
There are three different XML schemata registered in the DB
I may need to read the XML data from several tables.
If all the XMLTypes have the same XML schema ,there is no problem,
If the schemata are different, the second read throws BindXMLException.
If I reset the connection between the reads of the XMLType column with different schemata, it works.
The question is: how can I configure the driver, or the connection to be able to read the data with different XML schemata without resetting the connection (which is expensive).
The code to get the XMLType data is textbook implementation:
1 ResultSet resultSet = statement.executeQuery( sql ) ;
2 String result = null ;
3 while(resultSet.next()) {
4 SQLXML sqlxml = resultSet.getSQLXML(1) ;
5 result = sqlxml.getString() ;
6 sqlxml.free();
7 }
8 resultSet.close();
9 return result ;It turns out, that I needed to serialize the XML on the server and read it as Blob. Like this:
1 final Statement statement = connection.createStatement() ;
2 final String sql = String.format("select xmlserialize(content xml_content_column as blob encoding 'UTF-8') from %s where key='%s'", table, key ) ;
3 ResultSet resultSet = statement.executeQuery( sql ) ;
4 String result = null ;
5 while(resultSet.next()) {
6 Blob blob = resultSet.getBlob( 1 );
7 InputStream inputStream = blob.getBinaryStream();
8 result = new Scanner( inputStream ).useDelimiter( "\\A" ).next();
9 inputStream.close();
10 blob.free();
11 }
12 resultSet.close();
13 statement.close();
14
15 System.out.println( result );
16 return result ;
17
Then it works. Still, can't get it work with XMLType in resultset.On the client unwrapping XML blows up when trying to switch to different XML schema. JDBC/XDB problem? -
Bpelc issues with WSDL schema definition
Hi,
I have been attempting to deploy a relative simple BPEL example, developed using the BPEL Designer Eclipse plugin and deployed on BPEL Process Manager.
The BPEL consists of receiving a SOAP message, copying variables using assign from the input message to a message defined in an external WSDL, invoking that WSDL's service and copying the results of that service into the output message.
To design the external service, I developed a simple Java class in Apache Axis and used the Java2WSDL tool to create all the interfaces. I then copied that WSDL to the BPEL designer and started to design the BPEL.
The problem is to do with the definition of messages within the WSDL, the following snippet is from the WSDL generated in Apache Axis:
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://mdsuk.com/wsdl/example/PSP1">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="OutputCT">
<sequence>
<element name="message" nillable="true" type="xsd:string"/>
<element name="paymentReference" nillable="true" type="xsd:string"/>
<element name="success" nillable="true" type="xsd:boolean"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
I then tried to create the <assign> statement for the External Service Message -> BPEL Output Message using BPEL Designer using the visual editor, it generated the following code:
<assign name="assign-2">
<copy>
<from variable="pspOutput" part="outputCT" query="/message"></from>
<to variable="output" part="payload" query="/tns:OrderTestResponse/tns:result"/>
</copy>
<copy>
<from variable="pspOutput" part="outputCT" query="/success"></from>
<to variable="output" part="payload" query="/tns:OrderTestResponse/tns:success"/>
</copy>
</assign>
Trying to compile this generated code resulted in:
[bpelc] [Error ORABPEL-10057]: invalid query
[bpelc] [Description]: in line 94 of "D:\EclipseWorkspace\OrderTest\OrderTest.bpel", query "/message" is invalid, because step 'message' is not valid..
[bpelc] [Potential fix]: Check the XML schema and make sure your query string is valid.
[bpelc]
[bpelc] [Error ORABPEL-10057]: invalid query
[bpelc] [Description]: in line 98 of "D:\EclipseWorkspace\OrderTest\OrderTest.bpel", query "/success" is invalid, because step 'success' is not valid..
[bpelc] [Potential fix]: Check the XML schema and make sure your query string is valid.
So, the generated code from BPEL Designer was failing to compile. This resulted in a long check of the code, finally I realised that it expected the inputCT variable to be present in the XPath, so I manually changed the code to
<assign name="assign-2">
<copy>
<from variable="pspOutput" part="outputCT" query="/outputCT/message"></from>
<to variable="output" part="payload" query="/tns:OrderTestResponse/tns:result"/>
</copy>
<copy>
<from variable="pspOutput" part="outputCT" query="/outputCT/success"></from>
<to variable="output" part="payload" query="/tns:OrderTestResponse/tns:success"/>
</copy>
</assign>
This allowed to code to compile, so I deployed the BPEL to the Process Manager, and invoked a query using the Web Interface.
The BPEL started up fine, it invoked my external Axis Web Service, Axis produced the output (visible via debugging) however Process Manager tried to process the output, it crashed with the following exception:
06/01/19 16:29:11 com.oracle.bpel.client.BPELFault: faultName: {{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure}
messageType: {null}
parts: {{summary=<summary>empty variable/expression result.
xpath variable/expression expression "/outputCT/message" is empty at line 94, when attempting reading/copying it.
Please make sure the variable/expression result "/outputCT/message" is not empty.
</summary>}}
So, the compiled BPEL code, which had the WSDL schema to compare against was failing during execution, I inspected the output from the Axis Web Service, which was:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<processPaymentResponse xmlns="http://mdsuk.com/wsdl/example/PSP1">
<outputCT xmlns="">
<ns1:message xmlns:ns1="http://mdsuk.com/wsdl/example/PSP1">Payment Succesful</ns1:message>
<ns2:paymentReference xmlns:ns2="http://mdsuk.com/wsdl/example/PSP1">1137688175137</ns2:paymentReference>
<ns3:success xmlns:ns3="http://mdsuk.com/wsdl/example/PSP1">true</ns3:success>
</outputCT>
</processPaymentResponse>
</soapenv:Body>
</soapenv:Envelope>
The key difference was that the message / paymentReference and success attributes were prefixed with the namespace "http://mdsuk.com/wsdl/example/PSP1" , this makes sense as the schema has the attribute targetNamespace="http://mdsuk.com/wsdl/example/PSP1".
However, when I tried to modify the BPEL to read:
<assign name="assign-2">
<copy>
<from variable="pspOutput" part="outputCT" query="/outputCT/nsxml1:message"></from>
<to variable="output" part="payload" query="/tns:OrderTestResponse/tns:result"/>
</copy>
<copy>
<from variable="pspOutput" part="outputCT" query="/outputCT/nsxml1:success"></from>
<to variable="output" part="payload" query="/tns:OrderTestResponse/tns:success"/>
</copy>
</assign>
It complained:
[bpelc] [Error ORABPEL-10057]: invalid query
[bpelc] [Description]: in line 94 of "D:\EclipseWorkspace\OrderTest\OrderTest.bpel", query "/outputCT/nsxml1:message" is invalid, because step 'nsxml1:message' is not valid..
[bpelc] [Potential fix]: Check the XML schema and make sure your query string is valid.
[bpelc]
[bpelc] [Error ORABPEL-10057]: invalid query
[bpelc] [Description]: in line 98 of "D:\EclipseWorkspace\OrderTest\OrderTest.bpel", query "/outputCT/nsxml1:sucess" is invalid, because step 'nsxml1:sucess' is not valid..
[bpelc] [Potential fix]: Check the XML schema and make sure your query string is valid.
[bpelc] .
So, the BPEL would not validate against the WSDL schema that was being produced, I read up on the W3 Schema specification, and found that the schema can take the attribute elementFormDefault - this attribute takes the values 'qualified' or 'unqualified'. If qualified, then it explicitly states that all children elements should be beloning to the namespace of this element.
So, I changed the schema to read:
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://mdsuk.com/wsdl/example/PSP1"
elementFormDefault="qualified">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="OutputCT">
<sequence>
<element name="message" nillable="true" type="xsd:string"/>
<element name="paymentReference" nillable="true" type="xsd:string"/>
<element name="success" nillable="true" type="xsd:boolean"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
The BPEL compiled and ran succesfully.
However, the problem/issue here is, Oracle bpelc assumed that if the elementFormDefault attribute was missing from the schema definition, it defaulted to unqualified, even with the targetNamespace attribute present.
Axis and <oXygen/> XML Editors, in which I tested the WSDL code, assumed that if the elementFormDefault attribute was missing, it defaulted to qualified.
I cannot find anything in the Schema Specification to say which is correct - can anyone shed any light on this? I also want to make Oracle BPEL users aware of this issue.
Regards,
Peter DolukhanovI resolved this issue by adding the following to the 2nd schema in the wsdl
xmlns:xsdLocal1="urn:/crmondemand/xml/integrationevent"
inside the 2nd schema
<xsd:schema
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xsdLocal1="urn:/crmondemand/xml/integrationevent"
targetNamespace="urn:crmondemand/ws/integrationevent/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
and this line immediately below it
<xsd:import namespace="urn:/crmondemand/xml/integrationevent" />
I could then create a proxy class using wsdl.exe -
Error validating xml with xsd schema on JSDK 1.4
Hi All,
Asked to me do it a Web Service client in Java and validate its xml answer with an xsd file using 1.4 plataform.
I googled and I saw many samples to 1.5 plataform, and few samples to 1.4, but anyway I tried to do what they asked to me.
I got connect with service, got the response and so I went to validate that xml with an xsd file.
But I got an error on that task. The error occurs in the following line
"Schema schema = factory.getSchema();"
Bellow my code
final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
final String schemaSource = "C:\\GetAuthorizationServiceOutput.xsd";
final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
try {
factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
factory.setAttribute(JAXP_SCHEMA_SOURCE,new File(source));
catch (IllegalArgumentException x) {
System.out.println(x.getMessage());
DocumentBuilder builder = null;
Document document = null;
try {
builder = factory.newDocumentBuilder();
document = builder.parse(new InputSource(new StringReader(ret.toString())));
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
**Schema schema = factory.getSchema();**
Validator validator = schema.newValidator();
try {
validator.validate(new DOMSource(document));
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
and here is the exception :
Caused by: java.lang.NoSuchMethodError: javax.xml.parsers.DocumentBuilderFactory.getSchema()Ljavax/xml/validation/Schema;
Method onLinkClicked of interface wicket.markup.html.link.ILinkListener targeted at component [MarkupContainer [Component id = btBack, page = br.com.weev.finan.mkb_er.extranet.view.relations.RelationsDetails, path = 30:form:btBack.RelationsDetails$4, isVisible = true, isVersioned = true]] threw an exception
wicket.WicketRuntimeException: Method onLinkClicked of interface wicket.markup.html.link.ILinkListener targeted at component [MarkupContainer [Component id = btBack, page = br.com.weev.finan.mkb_er.extranet.view.relations.RelationsDetails, path = 30:form:btBack.RelationsDetails$4, isVisible = true, isVersioned = true]] threw an exception
at wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:198)
at wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:74)
at wicket.request.compound.DefaultEventProcessorStrategy.processEvents(DefaultEventProcessorStrategy.java:65)
at wicket.request.compound.AbstractCompoundRequestCycleProcessor.processEvents(AbstractCompoundRequestCycleProcessor.java:57)
at wicket.RequestCycle.doProcessEventsAndRespond(RequestCycle.java:896)
at wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:929)
at wicket.RequestCycle.step(RequestCycle.java:1010)
at wicket.RequestCycle.steps(RequestCycle.java:1084)
at wicket.RequestCycle.request(RequestCycle.java:454)
at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:219)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor342.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:187)
... 39 more
Caused by: java.lang.NoSuchMethodError: javax.xml.parsers.DocumentBuilderFactory.getSchema()Ljavax/xml/validation/Schema;
at br.com.weev.finan.mkb_er.business.manager.impl.RelationManagerImpl.getAuthorizationService(RelationManagerImpl.java:152)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy22.getAuthorizationService(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:377)
at wicket.proxy.$Proxy39.getAuthorizationService(Unknown Source)
at br.com.weev.finan.mkb_er.extranet.view.relations.RelationsDetails$4.onClick(RelationsDetails.java:125)
at wicket.markup.html.link.Link.onLinkClicked(Link.java:254)
... 43 more
It's my first time doing that, so I'm confuse to do it.
Thank you
Juliano.This is how.
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
dbfac.setNamespaceAware(true);
SchemaFactory factory1 = SchemaFactory
.newInstance("http://www.w3.org/2001/XMLSchema");
Schema schema = factory1.newSchema(new File("person.xsd"));
dbfac.setSchema(schema);
DocumentBuilder dbparser1 = dbfac.newDocumentBuilder();
Document doc1 = dbparser1.parse(new File("person.xml"));
Validator validator1 = schema.newValidator();
DOMSource dm1 = new DOMSource(doc1);
DOMResult domresult1 = new DOMResult();
validator1.validate(dm1, domresult1); -
Java code to access XML (with unknown SCHEMA)
Dear participants,
My name is Raghavendra , i have a requirement of reading XML files Dynamically and parse them and create java types for manipulation . i will not be provided with sxd files (no schema compilation )coz no one knows how many types of structures are there. i want a generic solution. Please Help.
Thanks ,
Raghavendra Ach
you can mail me to " [email protected]"JAXB has been available as an early release download for some time. There are also XML Binding packages available from Borland (JBuilder) and Castor. These tools create Java classes from a source document, xml,dtd etc. You can use these classes to marshal-unmarshal XML documents.
Dave -
Csv input adapter - read rows with different # of columns
I have a csv file which includes rows with different number of columns. I want to read all the rows( of different # of cols) into ONE stream only and then split into separate streams afterwards.
I saw that CSV File Input Adapter does not add missing columns with nulls by default. Is it possible somehow? How can I generate a workaround?
Thanks.Hello,
The CSV Input Adapter expects to find a fixed number of fields. If you attach the input adapter to a stream/window with 3 fields, it will always try to read three fields. You can have missing data and this will be read into a column as a NULL value but the delimiters must still be there. For example:
1,1,1
2,2,2
3,3,3
4,,4
5,5,5
CREATE INPUT WINDOW inWindow SCHEMA (c1 integer, c2 integer, c3 integer) PRIMARY KEY (c1);
ATTACH INPUT ADAPTER File_Hadoop_CSV_Input2 TYPE toolkit_file_csv_input TO inWindow PROPERTIES csvExpectStreamNameOpcode = FALSE ,
dir = 'c:/temp' ,
file = 'test.csv' ,
csvDelimiter = ',' ;
A workaround you might consider is reading an entire line from your file into a stream with a single string column. The trick is that you have to choose a character for the column delimiter that you are certain will never show up in your data. Than once you have read that line into a stream, you can use the string functions to parse out the columns as needed:
CREATE INPUT STREAM csv_instream SCHEMA (
log_line_message string
// Choose a character that is certain to never show up in the data in order to read the entire line
// from the CSV file into a single column
ATTACH INPUT ADAPTER File_Hadoop_CSV_Input1 TYPE toolkit_file_csv_input TO csv_instream PROPERTIES
csvExpectStreamNameOpcode = FALSE ,
dir = 'C:/temp' ,
file = 'error_log' ,
csvDelimiter = '@' ;
// Parse out the individual columns
CREATE OUTPUT STREAM csv_outstream SCHEMA (
log_datetime timestamp ,
debug_level string ,
host string ,
message string ) AS SELECT
to_timestamp(substr(CI.log_line_message, 1, 24), 'DY MON DD HH24:MI:SS YYYY') as log_datetime,
substr(CI.log_line_message, patindex(CI.log_line_message, '[', 2)+1, (patindex(CI.log_line_message, ']', 2) - patindex(CI.log_line_message, '[', 2))-1) AS debug_level,
replace(substr(CI.log_line_message, patindex(CI.log_line_message, '[', 3)+1, (patindex(CI.log_line_message, ']', 3) - patindex(CI.log_line_message, '[', 3))-1), 'client ', '') AS host,
substr(CI.log_line_message, patindex(CI.log_line_message, ']', 3)+1, 500) AS message
FROM csv_instream CI
WHERE CI.log_line_message IS NOT NULL;
Thanks,
Neal -
Can't read xml with a Reader?
hi,
is it correct that the java Reader classes for reading character streams can't be used for reading XML (in one-pass)?
ie you don't know what encoding to read the file as until you've read the encoding attribute of the top level tag - and by then its too late - you'd have to start again?
(i think this is how xml parsers must work?)
thanks,
asjfto be honest this was motivated by wanting a quick method to remove the DTD reference from an inputstream, without having to worry about whichever XML API was in use further down in the code (we've since settled on a particular API so this is no longer an issue)
I've been told there are 2 legitimate ways to do this (with the help of the parser)
A) configure the parser (parser-implementation-dependent)
B) in SAX, provide an EntityResolver
Last year I had opted for a gratuitous munge-around by manually reading the inputstream and removing the DTD reference
this year we've started working with chinese documents.. so the code doesn't work since I was using the platform-encoding rather than the xml-declared encoding
its pretty clear that (B) is the way to go but there are a few other technical hurdles to overcome first..
i'm beginning to think that /all/ quick-workarounds come back to bite you soon enough.. -
Create different log file with different schema by spool
Hello,
I want to know a way to create a different log file depend on different schema
I have two schema on same db server
1) schema kennam/*****/kennam
2) schema koonhey/*****/koonhey
by a way, I want to create a different log file name e.g. kennam.log / koonhey.log on such two schema...
I always run @showbalance; to run showbalance.sql to create that report..
I hope you understand what I talking about (english is not my native language........), anyone could help?
showbalancelog.sql
spool c:\log.log+
spool c:\log.log
select to_char(sysdate,'dd-mm-yyyy hh:mi:ss') from dual;
column com_name format a20;
select cus.tid, cus.com_name com_name, cus.com_balance,
NVL((select sum(invoice_total) from invoice where com_id=cus.tid),0) sum_invoice,
NVL((select sum(cheque_amount) from income where com_id=cus.tid),0) sum_income,
cus.com_balance -
NVL((select sum(invoice_total) from invoice where com_id=cus.tid),0) +
NVL((select sum(cheque_amount) from income where com_id=cus.tid),0) total_balance
from customers cus
order by cus.tid;
spool offokey I solved on this way, is anyone know another simpler way?
be simpler part
variable vspoolfile varchar2(20)
declare
username varchar2(20);
spoolfile varchar2(50);
begin
select 'c:\' || user || '.log' into spoolfile from dual;
-- spoolfile := 'c:\' || username || '.log';
:vspoolfile := spoolfile;
-- dbms_output.PUT_LINE(spoolfile);
end;
-- print :vspoolfile;
column spoolfilecol new_value definespoolfile noprint
select :vspoolfile spoolfilecol from dual;full content of my showbalancelog.sql file
variable vspoolfile varchar2(20)
declare
username varchar2(20);
spoolfile varchar2(50);
begin
select 'c:\' || user || '.log' into spoolfile from dual;
-- spoolfile := 'c:\' || username || '.log';
:vspoolfile := spoolfile;
-- dbms_output.PUT_LINE(spoolfile);
end;
-- print :vspoolfile;
column spoolfilecol new_value definespoolfile noprint
select :vspoolfile spoolfilecol from dual;
spool &definespoolfile;
column com_name format a20;
select cus.tid, cus.com_name com_name, cus.com_balance,
NVL((select sum(invoice_total) from invoice where com_id=cus.tid),0) sum_invoice,
NVL((select sum(cheque_amount) from income where com_id=cus.tid),0) sum_income,
cus.com_balance -
NVL((select sum(invoice_total) from invoice where com_id=cus.tid),0) +
NVL((select sum(cheque_amount) from income where com_id=cus.tid),0) total_balance
from customers cus
order by cus.tid;
spool off; -
After Redirected Restore with different schema problems with db13
Hello, we made a redirected restore. We have different schema between production and quality system.
According to note 713524 we made the following changes:
create db connect user from the source system in the target system (unix user, sap<sid>)
set parameter dbs/db6/schema=sap<sid> in the instance profile
set dbs_db6_schema = sap<sid> in the environment for <sid>adm and db2<sid> (dbenv...)
add user sap<sid> into /sapmnt/<SID>/global/dscdb6.conf and set password with dscdb6up sap<sid> <password>
The system is now up and running. But transaction db13 is not working
SQL0443N Routine "*SHOT_DBM" (specific name "")
has returned an error SQLSTATE with diagnostic
text "SQL1092 Reason code or token: SAPR3
". SQLSTATE=38553
Regards,
AlexanderHi Alexander
sorry , forget the grants , they should come from the source system .
If you have multiple App-Servers , did you perform the above mentioned action in all affected profiles and environments of your Q-System ?
Please check , if you can limit this issue to an separate App-Server or to all App-Servers .
Best regards
dirk -
Reading xml with streamtokenizer
Does anyone know how to read xml tags (everthing in between < & >) with streamtokenizer, I can't find any tutorials.
I recommend xml packages. It's a bit more complex, IMO.
-
Combine multiple oracle 10g db as one 11g database with different schemas
We have 3 10g databases on a solaris machine
We are planning to migrate them and upgrade to 11g rel2 on linux machine
and finally merge those into one database as different schemas
has anyone got good ideas of the best strategy to do that
thankshas anyone got good ideas of the best strategy to do thatexpdp/impdp
-
How to validate an xml with a schema w/o specifying the schema in the xml
I have done xml validation with xml schemas, where the xml points to the xsd to use. However, I would like to not have to specifiy the xml schema in the xml document (and can't ensure that the xml coming to us has that in it). How do I, in the java code, tell it what schema to use in validation?
Brianstatic final String schemaSource = argv[0];
static final String JAXP_SCHEMA_SOURCE =
"http://java.sun.com/xml/jaxp/properties/schemaSource";
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setAttribute(JAXP_SCHEMA_SOURCE,
new File(schemaSource)); -
Validate xml with complextype schema without root element!
Hi All!
I have a problem that. I want to validate a xml data of complextype but the schema i want to validate is[b] not have root element.
For example:
The schema like that
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="www.thachpn.test" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="www.thachpn.test" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="Name">
<xs:sequence>
<xs:element name="FirstName" type="xs:string"/>
<xs:element name="LastName" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
and the xml data i want to validate like this
<?xml version="1.0" encoding="UTF-8"?>
<Name xmlns="www.thachpn.test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<FirstName>Pham</FirstName>
<LastName>Thach</LastName>
</Name>
My Algorithm is like that:
I create a complextype object by above schema
then i create new element with given name and namespace
after that i use schema of this element to validate xml data.
I use xmlparserv2 lib of oracle
But i can not find how to create complextype from schema or create element with have complextype.
Please help me.
Thanks a lot!<?xml version="1.0" encoding="UTF-8"?>
Modify the schema.
Add a root element.
<xs:schema targetNamespace="www.thachpn.test" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="www.thachpn.test" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xsd:element name="Name" type="Name"/>
<xs:complexType name="Name">
<xs:sequence>
<xs:element name="FirstName" type="xs:string"/>
<xs:element name="LastName" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema> -
Systemcopy: problems with different schema users
Hi,
I'm working on a systemcopy of an abap system with java addin. It is an Netweaver 7.01 SR1 installation.
The oracle version is 10.2.0.4.
The following problem occoured:
The source system had the ID P13. Therefore the schema users were SAPP13 and SAPP13DB.
The traget system has the ID P14. Therefore normally the schema users are SAP14 and SAPP14DB.
I read oss note 534765 I changed the dbs_ora_schema to the old ABAP schema, and the installtion of the abap went trough.
But now it stopps in the java part "Run Java migration tool kit".
The installtion wants to get information from the table SAPP14DB.j2ee_config which is not existent, but the table SAPP13DB.j2ee_config is existent.
I tried to change the scheme name in the keydb.xml and the inifile.xml in the installtion directory, and restaret the installation, but it still does not work.
Has anyone an idea how ti solve it?
Regards
UlrikeHi Ashish,
here is the log file runJmt.log:
com.sap.engine.frame.core.configuration.ConfigurationException: Error occurred d
uring DB access: cluster_data/dispatcher,
at com.sap.engine.core.configuration.impl.persistence.rdbms.PersistenceH
andler.readConfig(PersistenceHandler.java:108)
at com.sap.engine.core.configuration.impl.cache.CachedConfiguration.<ini
t>(CachedConfiguration.java:62)
at com.sap.engine.core.configuration.impl.cache.ConfigurationCache.getCa
chedConfiguration(ConfigurationCache.java:848)
at com.sap.engine.core.configuration.impl.cache.ConfigurationCache.getCa
chedConfiguration(ConfigurationCache.java:882)
at com.sap.engine.core.configuration.impl.cache.ConfigurationCache.openC
onfiguration(ConfigurationCache.java:748)
at com.sap.engine.core.configuration.impl.ConfigurationHandlerImpl.openC
onfiguration(ConfigurationHandlerImpl.java:734)
at com.sap.engine.core.configuration.impl.ConfigurationHandlerImpl.openC
onfiguration(ConfigurationHandlerImpl.java:693)
at com.sap.sdt.serviceframework630.impl.ClusterDataImpl._getSourceIds0(C
lusterDataImpl.java:54)
at com.sap.sdt.serviceframework630.impl.ClusterDataImpl.getDispatcherIds
(ClusterDataImpl.java:91)
at com.sap.sdt.serviceframework630.impl.ClusterDataImpl.createIdMapping(
ClusterDataImpl.java:172)
at com.sap.sdt.jmt.migrationtool.MigrationToolImport.prepareSwitch(Migra
tionToolImport.java:1129)
at com.sap.sdt.jmt.migrationtool.MigrationToolImport.startTool(MigrationToolImport.java:403)
at com.sap.sdt.jmt.migrationtool.MigrationToolImport.main(MigrationToolImport.java:1561)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:61)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
at java.lang.reflect.Method.invoke(Method.java:391)
at com.sap.engine.offline.OfflineToolStart.main(OfflineToolStart.java:81)
Caused by: java.sql.SQLException: ORA-00942: table or view does not exist
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:745)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:219)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:813)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1049)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:85
4)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1154)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3
370)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3415
at com.sap.sql.jdbc.basic.BasicPreparedStatement.executeQuery(BasicPreparedStatement.java:97
at com.sap.sql.jdbc.direct.DirectPreparedStatement.executeQuery(DirectPreparedStatement.java
:281)
at com.sap.sql.jdbc.direct.DirectPreparedStatement.executeQuery(DirectPreparedStatement.java
:248)
at com.sap.engine.core.configuration.impl.persistence.rdbms.DBAccessDefault.getConfiguration
(DBAccessDefault.java:578)
at com.sap.engine.core.configuration.impl.persistence.rdbms.PersistenceHandler.readConfig(Pe
rsistenceHandler.java:102)
... 18 more
com.sap.engine.frame.core.configuration.ConfigurationException: Error occurred during DB access: clu
ster_data/dispatcher,
at com.sap.engine.core.configuration.impl.persistence.rdbms.PersistenceHandler.readConfig(Pe
rsistenceHandler.java:108)
at com.sap.engine.core.configuration.impl.cache.CachedConfiguration.<init>(CachedConfigurati
on.java:62)
at com.sap.engine.core.configuration.impl.cache.ConfigurationCache.getCachedConfiguration(Co
nfigurationCache.java:848)
at com.sap.engine.core.configuration.impl.cache.ConfigurationCache.getCachedConfiguration(Co
nfigurationCache.java:882)
at com.sap.engine.core.configuration.impl.cache.ConfigurationCache.openConfiguration(Configu
rationCache.java:748)
at com.sap.engine.core.configuration.impl.ConfigurationHandlerImpl.openConfiguration(Configu
rationHandlerImpl.java:734)
at com.sap.engine.core.configuration.impl.ConfigurationHandlerImpl.openConfiguration(Configu
rationHandlerImpl.java:693)
at com.sap.sdt.serviceframework630.impl.ClusterDataImpl._getSourceIds0(ClusterDataImpl.java:
54)
at com.sap.sdt.serviceframework630.impl.ClusterDataImpl.getDispatcherIds(ClusterDataImpl.jav
a:91)
at com.sap.sdt.serviceframework630.impl.ClusterDataImpl.createIdMapping(ClusterDataImpl.java
:172)
at com.sap.sdt.jmt.migrationtool.MigrationToolImport.prepareSwitch(MigrationToolImport.java:
1129)
at com.sap.sdt.jmt.migrationtool.MigrationToolImport.startTool(MigrationToolImport.java:403)
at com.sap.sdt.jmt.migrationtool.MigrationToolImport.main(MigrationToolImport.java:1561)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:61)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
at java.lang.reflect.Method.invoke(Method.java:391)
at com.sap.engine.offline.OfflineToolStart.main(OfflineToolStart.java:81)
Caused by: java.sql.SQLException: ORA-00942: table or view does not exist
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:745)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:219)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:813)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1049)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:85
4)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1154)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3
370)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3415
at com.sap.sql.jdbc.basic.BasicPreparedStatement.executeQuery(BasicPreparedStatement.java:97
at com.sap.sql.jdbc.direct.DirectPreparedStatement.executeQuery(DirectPreparedStatement.java
:281)
at com.sap.sql.jdbc.direct.DirectPreparedStatement.executeQuery(DirectPreparedStatement.java
:248)
at com.sap.engine.core.configuration.impl.persistence.rdbms.DBAccessDefault.getConfiguration
(DBAccessDefault.java:578)
at com.sap.engine.core.configuration.impl.persistence.rdbms.PersistenceHandler.readConfig(Pe
rsistenceHandler.java:102)
... 18 more
Error executing Migration Tool Import
java.lang.IllegalArgumentException
at com.sap.sdt.serviceframework630.impl.ClusterDataImpl.createBoxNumberMapping(ClusterDataIm
pl.java:137)
at com.sap.sdt.serviceframework630.impl.ClusterDataImpl.createIdMapping(ClusterDataImpl.java
:172)
at com.sap.sdt.jmt.migrationtool.MigrationToolImport.prepareSwitch(MigrationToolImport.java:
1129)
at com.sap.sdt.jmt.migrationtool.MigrationToolImport.startTool(MigrationToolImport.java:403)
at com.sap.sdt.jmt.migrationtool.MigrationToolImport.main(MigrationToolImport.java:1561)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:61)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
at java.lang.reflect.Method.invoke(Method.java:391)
at com.sap.engine.offline.OfflineToolStart.main(OfflineToolStart.java:81)
Additiononal information are int the log file /tmp/sapinst_instdir/NW701/LM/COPY/ORA/SYSTEM/CENTRAL/AS/jmt/
system.log
#1.5^H#C00086F783A30000000000150C720C72000482F1A7986410#1269874317354#/System/Database/sql/jdbc/direct##com.sap.sql.jdbc.direct.DirectPreparedStatement#######Thread[main,5,main]##0#0#Error#1#com.sap.sql.jdbc.direct.DirectPreparedStatement#Java#com.sap.sql_0003#com.sap.sql.log.OpenSQLResourceBundle#SQL error occurred on connection : code={0,number,integer}, state="", message="";
SQL statement is "".#5#942#42000#ORA-00942: table or view does not exist
#fmgp14:P14:SAPP14DB#SELECT "CPATH","CID","PARENTCID","CACHEMODE","CTYPE" FROM "J2EE_CONFIG" WHERE "PATHHASH" = ?#
#1.5^H#C00086F783A30000000000160C720C72000482F1A79867F8#1269874317355#/System/Server##com.sap.engine.core.configuration#######Thread[main,5,main]##0#0#Error#1#com.sap.engine.core.configuration#Plain###ORA-00942: table or view does not exist
Regards
Ulrike
Maybe you are looking for
-
Macbook Pro Hard drive partition and Bootcamp Info.plist
Okays, so i was planning on installing windows through USB bootcamp as my CD is broken. I tried editing the Info.Plist and i managed to stuff it up and lost original now it doesnt work, how do i redownload my original one. THEN i tried to partition t
-
I get the error message 4 to 6 times a day. Since I don't ever remember signing up for Messenger, I'm puzzled by the message. I can't find Messenger in my applications file (or anywhere else) so I can't delete or un-install the program. At first it w
-
Finding warehouse number with storage location
Hi all, How can I find the warehouse number given the material, plant and the storage location? Thanks in advance.
-
Hello, In the context of an upgrade of e-recruiting (from 3.0 to 6.0) we installed a new Trex (release 7.10). I recreated all indexes and I have problems with two files. This files are uploaded by applicant and they are encrypted. I have errors into
-
Assembly processing profit center
Dear all, i trigger the project by saving the sales order. there is a problem. when i check the project using CJ20N, i found that the profit center is DUMMY in the basic data. the profit center should be automatically genenrated in line with the mate