Author |
Message
|
sarasu |
Posted: Tue Jul 02, 2013 9:23 am Post subject: XSD Pattern Validation |
|
|
Master
Joined: 02 Feb 2006 Posts: 229
|
All,
We are using WMB8.0.0.2 OS: z/Linux
B is a mandatory field defined by the patterns.
Works: get correct validation error as Text:CHARACTER:cvc-pattern-valid: The value "" is not valid with respect to the pattern facet for type "#Anonymous".
<A>
<B></B>
</A>
Doesn’t Work: Get a parser exception as Text:CHARACTER:cvc-complex-type.2.4.g: The content of element "B" is not complete. Empty tag is not expected since the content type is not 'empty'.
<A>
<B/>
</A>
Pattern definition of B
\d{1,2}
Thanks |
|
Back to top |
|
 |
lancelotlinc |
Posted: Tue Jul 02, 2013 10:13 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
The problem is : Empty tag is not expected since the content type is not 'empty'.
Don't send empty B tags or change your schema to include empty fields in B. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
sarasu |
Posted: Tue Jul 02, 2013 11:36 am Post subject: |
|
|
Master
Joined: 02 Feb 2006 Posts: 229
|
Thanks for your response.
But we want to validate this field even if it is empty value.
If we allow it to accept the empty value then it becomes an optional field.
We want it to be mandatory and catch the XSD validation error.
Need to validate both Scenarios:
1. Working as expected
<A>
<B></B>
</A>
2. This is failing.
<A>
<B/>
</A>
Thanks |
|
Back to top |
|
 |
lancelotlinc |
Posted: Tue Jul 02, 2013 11:44 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Then your left with setting the field to optional and writing ESQL code to check it. If the field fails your ESQL validation, throw an error. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
sarasu |
Posted: Tue Jul 02, 2013 11:52 am Post subject: |
|
|
Master
Joined: 02 Feb 2006 Posts: 229
|
Thanks for the Inputs.
But we want to validate Out of box only.
Thanks |
|
Back to top |
|
 |
Vitor |
Posted: Wed Jul 03, 2013 2:19 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
sarasu wrote: |
But we want to validate Out of box only. |
Why? Does your box not contain ESQL?
The W3C XML standard does not accept the concept of a mandatory optional field. Hence you can't write an XSD that describes it, hence you can't simply validate against the schema. Your problem is not a WMB one but an XML one.
Find a way to explain this in a schema & WMB will validate it. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
shanson |
Posted: Wed Jul 03, 2013 3:05 am Post subject: |
|
|
 Partisan
Joined: 17 Oct 2003 Posts: 344 Location: IBM Hursley
|
sarasu, please can you post the element declaration for B from the xsd? I ask because the error message for <B/> is a complex type error message, if your element is an ordinary simple type then that does not sound right. |
|
Back to top |
|
 |
sarasu |
Posted: Wed Jul 03, 2013 5:48 am Post subject: |
|
|
Master
Joined: 02 Feb 2006 Posts: 229
|
Thanks for your responses.
But if we have it as <B></B> under XSD validation is working as expected from Broker.
But if we use it as <B\> why it is going to the root element ?
--> We have declared element <B> as a complex element type only. |
|
Back to top |
|
 |
shanson |
Posted: Wed Jul 03, 2013 6:04 am Post subject: |
|
|
 Partisan
Joined: 17 Oct 2003 Posts: 344 Location: IBM Hursley
|
Please post the element declaration as requested. |
|
Back to top |
|
 |
sarasu |
Posted: Wed Jul 03, 2013 6:31 am Post subject: |
|
|
Master
Joined: 02 Feb 2006 Posts: 229
|
Element Declaration:
Code: |
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:dfdlCobolFmt="http://www.ibm.com/dfdl/CobolDataDefinitionFormat" xmlns:ibmDfdlExtn="http://www.ibm.com/dfdl/extensions" xmlns:ibmSchExtn="http://www.ibm.com/schema/extensions" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.ibm.com/dfdl/CobolDataDefinitionFormat" schemaLocation="IBMdefined/CobolDataDefinitionFormat.xsd"/>
<xsd:complexType name="MV">
<xsd:sequence>
<xsd:element dfdl:lengthKind="implicit" name="A">
<xsd:complexType>
<xsd:sequence>
<xsd:element dfdl:length="2" ibmDfdlExtn:sampleValue="aa" name="B">
<xsd:annotation>
<xsd:appinfo source="http://www.wsadie.com/appinfo">
<initialValue kind="SPACE"/>
</xsd:appinfo>
<xsd:documentation>PIC X(2) display</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="dfdlCobolFmt:PICX__string">
<xsd:maxLength value="2"/>
<xsd:minLength value="0"/>
<xsd:pattern value="\d{1,2}"/>
<xsd:enumeration value="41"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:annotation>
<xsd:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:format binaryFloatRep="{$dfdl:binaryFloatRep}" byteOrder="{$dfdl:byteOrder}" encoding="{$dfdl:encoding}" ignoreCase="yes" leadingSkip="0" occursCountKind="fixed" ref="dfdlCobolFmt:CobolDataFormat" textNumberPadCharacter="0" textStringJustification="left" textStringPadCharacter="%SP;" textZonedSignStyle="asciiStandard" trailingSkip="0"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:element dfdl:lengthKind="implicit" ibmSchExtn:docRoot="true" name="MV" type="MV"/>
</xsd:schema> |
Exception:
Code: |
Number:INTEGER:5025
Text:CHARACTER:A schema validation error has occurred while parsing the XML document
Insert
Type:INTEGER:2
Text:CHARACTER:5010
Insert
Type:INTEGER:2
Text:CHARACTER:2
Insert
Type:INTEGER:2
Text:CHARACTER:15
Insert
Type:INTEGER:2
Text:CHARACTER:40
Insert
Type:INTEGER:5
Text:CHARACTER:cvc-complex-type.2.4.g: The content of element "B" is not complete. Empty tag is not expected since the content type is not 'empty'.
Insert
Type:INTEGER:5
Text:CHARACTER:/XMLNSC/http://schemas.xmlsoap.org/soap/envelope/:Envelope/http://schemas.xmlsoap.org/soap/envelope/:Body/http://MV:MVOperation/MV_In/A
|
|
|
Back to top |
|
 |
shanson |
Posted: Wed Jul 03, 2013 6:47 am Post subject: |
|
|
 Partisan
Joined: 17 Oct 2003 Posts: 344 Location: IBM Hursley
|
OK, so the xsd shows that you have declared B as a simple element, not as a complex element. I'm not sure why you said it was complex in your earlier append?
The element was generated by the DFDL COBOL importer, and its type is an anonymous restriction of a restriction of xs:string. I am wondering if this 'double restriction' is causing the parser a problem. Please can you change the xsd as below so that the type is an anonymous restriction of xs:string, and see if it makes any difference?
Code: |
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:dfdlCobolFmt="http://www.ibm.com/dfdl/CobolDataDefinitionFormat" xmlns:ibmDfdlExtn="http://www.ibm.com/dfdl/extensions" xmlns:ibmSchExtn="http://www.ibm.com/schema/extensions" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.ibm.com/dfdl/CobolDataDefinitionFormat" schemaLocation="IBMdefined/CobolDataDefinitionFormat.xsd"/>
<xsd:complexType name="MV">
<xsd:sequence>
<xsd:element dfdl:lengthKind="implicit" name="A">
<xsd:complexType>
<xsd:sequence>
<xsd:element dfdl:length="2" ibmDfdlExtn:sampleValue="aa" name="B">
<xsd:annotation>
<xsd:appinfo source="http://www.wsadie.com/appinfo">
<initialValue kind="SPACE"/>
</xsd:appinfo>
<xsd:documentation>PIC X(2) display</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xs:string">
<xsd:maxLength value="2"/>
<xsd:minLength value="0"/>
<xsd:pattern value="\d{1,2}"/>
<xsd:enumeration value="41"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:annotation>
<xsd:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:format binaryFloatRep="{$dfdl:binaryFloatRep}" byteOrder="{$dfdl:byteOrder}" encoding="{$dfdl:encoding}" ignoreCase="yes" leadingSkip="0" occursCountKind="fixed" ref="dfdlCobolFmt:CobolDataFormat" textNumberPadCharacter="0" textStringJustification="left" textStringPadCharacter="%SP;" textZonedSignStyle="asciiStandard" trailingSkip="0"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:annotation>
<xsd:documentation>
</xsd:documentation>
</xsd:annotation>
<xsd:element dfdl:lengthKind="implicit" ibmSchExtn:docRoot="true" name="MV" type="MV"/>
</xsd:schema>
|
|
|
Back to top |
|
 |
sarasu |
Posted: Wed Jul 03, 2013 7:12 am Post subject: |
|
|
Master
Joined: 02 Feb 2006 Posts: 229
|
Still got the same exception:
Code: |
Number:INTEGER:5025
Text:CHARACTER:A schema validation error has occurred while parsing the XML document
Insert
Type:INTEGER:2
Text:CHARACTER:5010
Insert
Type:INTEGER:2
Text:CHARACTER:2
Insert
Type:INTEGER:2
Text:CHARACTER:7
Insert
Type:INTEGER:2
Text:CHARACTER:40
Insert
Type:INTEGER:5
Text:CHARACTER:cvc-complex-type.2.4.g: The content of element "B" is not complete. Empty tag is not expected since the content type is not 'empty'.
Insert
Type:INTEGER:5
Text:CHARACTER:/XMLNSC/http://schemas.xmlsoap.org/soap/envelope/:Envelope/http://schemas.xmlsoap.org/soap/envelope/:Body/http://MV:MVOperation/MV_In/A |
|
|
Back to top |
|
 |
shanson |
Posted: Wed Jul 03, 2013 8:11 am Post subject: |
|
|
 Partisan
Joined: 17 Oct 2003 Posts: 344 Location: IBM Hursley
|
Personally I think that this is a bug and for the XSD quoted above the behavior should be the same, or at least closer than it is. Please raise a PMR and we will take it from there. Please reference this discussion in the PMR. |
|
Back to top |
|
 |
sarasu |
Posted: Wed Jul 03, 2013 11:11 am Post subject: |
|
|
Master
Joined: 02 Feb 2006 Posts: 229
|
Opened a PMR 91995 7TD 000 on this.
Thanks |
|
Back to top |
|
 |
|