Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

XSD Validation, checking for required elements

573589Apr 20 2007 — edited May 13 2008
I'm using the FTP Adapter to retrieve a flat file in a format like this -

H|1|1234|5-APR-2007
L|1|33123|2
L|1|12345|1
L|1|6969|5
S|1|Milton Park, Abingdon, OX142NF

I have generated an XSD file using the built in wizard that looks like this -

<?xml version="1.0" encoding="UTF-8" ?>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
targetNamespace="http://bpelns.corp.rmd.org/complex"
xmlns:tns="http://bpelns.corp.rmd.org/complex"
elementFormDefault="qualified"
attributeFormDefault="unqualified" nxsd:encoding="ASCII" nxsd:stream="chars" nxsd:version="NXSD">
<xsd:element name="order">
<xsd:complexType>
<xsd:choice minOccurs="1" maxOccurs="unbounded" nxsd:choiceCondition="terminated" nxsd:terminatedBy="|">
<xsd:element name="HEADER" minOccurs="1" maxOccurs="1" nillable="false" nxsd:conditionValue="H">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ORDERID" nillable="false" minOccurs="1" maxOccurs="1" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="|" nxsd:quotedBy="&quot;">
</xsd:element>
<xsd:element name="CUSTOMERID" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="|" nxsd:quotedBy="&quot;">
</xsd:element>
<xsd:element name="ORDERDATE" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="&quot;">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="LINEITEM" minOccurs="1" maxOccurs="unbounded" nxsd:conditionValue="L">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ORDERID" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="|" nxsd:quotedBy="&quot;">
</xsd:element>
<xsd:element name="PRODUCTCODE" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="|" nxsd:quotedBy="&quot;">
</xsd:element>
<xsd:element name="QUANTITY" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="&quot;">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="SHIPPING" minOccurs="1" maxOccurs="1" nxsd:conditionValue="S">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ORDERID" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="|" nxsd:quotedBy="&quot;">
</xsd:element>
<xsd:element name="ADDRESS" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="&quot;">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>


I added the various minOccurs & maxOccurs attributes. I would like to be able to state that the element HEADER is required. However, despite the min & max values it carries straight through to the next point in the BPEL flow. I cannot use the required attribute type, as JDeveloper does not recognise this.

How can I acheive the validation I require ? Is the XSD the right place to be doing it (I thought so, as it is the schema definition) ? If I cannot do this with the XSD how else might I acheive it in a concise way, ie not using a big switch operation to test various elements.

Comments

206307
In the BPEL Console, on manage domain's you can enable or disable the XML validation on the input and output of the BPEL instance. By default it is set 'Off'.

Marc
http://orasoa.blogspot.com
573589
That doesn't have the expected effect. It causes the XSD to be validated, but I then get this error -

Error::cvc-type.3.1.3: The value 'L' of element 'ORDERID' is not valid.
Error::cvc-datatype-valid.1.2.1: '12345|1' is not a valid value for 'integer'.
Error::cvc-type.3.1.3: The value '12345|1' of element 'QUANTITY' is not valid.
Error::cvc-datatype-valid.1.2.1: 'L' is not a valid value for 'integer'.
Error::cvc-type.3.1.3: The value 'L' of element 'ORDERID' is not valid.
Error::cvc-datatype-valid.1.2.1: '6969|5' is not a valid value for 'integer'.
Error::cvc-type.3.1.3: The value '6969|5' of element 'QUANTITY' is not valid.
Error::cvc-datatype-valid.1.2.1: 'S' is not a valid value for 'integer'.
Error::cvc-type.3.1.3: The value 'S' of element 'ORDERID' is not valid.

It seems to be out of step with the current element being processed, in other words for the line

L|1|33123|2

when it is reading in 'L' it is applying the rules for '1'. It is worth noting that without the validation turned on a file that is complete is processed as expected.
573589
I have just noticed that the XSD is creating the following XML document, which explains the validation failure. After the header it is treating everything else as a line item.

<?xml version="1.0" encoding="UTF-8" ?>
<order xmlns="http://bpelns.corp.rmd.org/complex">
<HEADER>
<ORDERID>1</ORDERID>
<CUSTOMERID>1234</CUSTOMERID>
<ORDERDATE>5-APR-2007</ORDERDATE>
</HEADER>
<LINEITEM>
<ORDERID>1</ORDERID>
<PRODUCTCODE>33123</PRODUCTCODE>
<QUANTITY>2</QUANTITY>
</LINEITEM>
<LINEITEM>
<ORDERID>L</ORDERID>
<PRODUCTCODE>1</PRODUCTCODE>
<QUANTITY>12345|1</QUANTITY>
</LINEITEM>
<LINEITEM>
<ORDERID>L</ORDERID>
<PRODUCTCODE>1</PRODUCTCODE>
<QUANTITY>6969|5</QUANTITY>
</LINEITEM>
<LINEITEM>
<ORDERID>S</ORDERID>
<PRODUCTCODE>1</PRODUCTCODE>
<QUANTITY>65 Milton Park, Abingdon, OX142NF</QUANTITY>
</LINEITEM>

</order>
206307
In your xsd you mention: nxsd:quotedBy="&quot;", but the example data is without the ".
564913
Hi,

I have set the validateXML option to true in the "Manage BPEL Domain" section and it is validating every xml that is passing through the BPEL process (input and output xmls).

My question is: Is it possible to only validate the input xml? If so, how can I do it?

Thanks in advance,
Zaloa
400882
I seem to remember reading a blog or whitepaper (brought to my attention via a colleague [he's not in today so can't refer to him]) in the oracle soa sphere regarding bpel xsd validation via a dedicated/separated bpel process. The context was being able to trap an XSD validation error and handle it internal to the process.

Refer to "Validating a xml aggainst a schema" and user599106 (I just found my reference to it).

HTH
637019
I myself had pretty bad experience with inbuilt soasuite "validate payload" functiionlity.

- For your issue, you should not turn on domain level validation, but you can specify validatePayload for specific bpel process

- Here is what I did: I created light weight java xml validator using my java program and exposed it as service, and then call whenever required, it worked like a charm.

HTH,
Chintan
Eric Elzinga
You could add the validateXML property just on the client partnerlink.
1 - 8
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 10 2008
Added on Apr 20 2007
8 comments
1,937 views