xerces schema validation: funny minOccurs behaviour

Discussion in 'XML' started by mstilli@gmail.com, Jan 24, 2007.

  1. Guest

    Hi,

    I am trying to use schema for server side validation using xerces to
    catch the validation errors.

    validating this XML:

    <Content4>
    <textarea13></textarea13>
    <binaryobject3></binaryobject3>
    </Content4>

    against this schema:

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsd:element name="Content4" type="contentType"/>

    <xsd:complexType name="contentType">
    <xsd:sequence>
    <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    <xsd:element minOccurs="1" name="text16" type="text16"/>
    <xsd:element name="textarea13" type="textarea13"/>
    <xsd:element minOccurs="0" name="binaryobject3"
    type="binaryobject3"/>
    </xsd:sequence>
    </xsd:complexType>

    <xsd:simpleType name="text16">
    <xsd:restriction base="xsd:string"/>
    </xsd:simpleType>

    <xsd:simpleType name="textarea13">
    <xsd:restriction base="xsd:string">
    <xsd:minLength value="1"/>
    </xsd:restriction>
    </xsd:simpleType>

    <xsd:complexType name="binaryobject3">
    <xsd:attribute name="filename"/>
    </xsd:complexType>

    <xsd:complexType name="metainfo">
    <xsd:sequence>
    <xsd:any maxOccurs="unbounded" minOccurs="0"
    processContents="skip"/>
    </xsd:sequence>
    <xsd:anyAttribute processContents="skip"/>
    </xsd:complexType>

    </xsd:schema>

    output these messages:

    cvc-complex-type.2.4.a: Invalid content was found starting with
    element 'textarea13'.
    One of '{metainfo, text16}' is expected.
    -------------^

    This message seems to me a little wrong, given

    <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    ----------------------------------------^

    Perhaps I'm missing something, but as far as I understood, if this
    atribute value is set to 0 the element is *optional*, thus can't figure
    why xerces doesn't discriminate and report "one of those is expected".

    I would expect it to report only about the mandatory element(s)
    missing, and not the whole sequence...

    I googled this but found nothing. Am I missing something?




    The other messages are just as expected...

    cvc-minLength-valid: Value '' with length = '0' is not facet-valid with
    respect to minLength '1' for type 'textarea13'.
    cvc-type.3.1.3: The value '' of element 'textarea13' is not valid.

    Thanks

    marcello stillitano
     
    , Jan 24, 2007
    #1
    1. Advertising

  2. George Bina Guest

    Hi,

    Xerces does not tell you that you *must* enter metainfo, it just says
    that it expects to find one of those elements at that position in the
    document.

    Best Regards,
    George
    ---------------------------------------------------------------------
    George Cristian Bina
    <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
    http://www.oxygenxml.com

    On Jan 24, 1:07 pm, wrote:
    > Hi,
    >
    > I am trying to use schema for server side validation using xerces to
    > catch the validation errors.
    >
    > validating this XML:
    >
    > <Content4>
    > <textarea13></textarea13>
    > <binaryobject3></binaryobject3>
    > </Content4>
    >
    > against this schema:
    >
    > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    > xmlns:fo="http://www.w3.org/1999/XSL/Format">
    > <xsd:element name="Content4" type="contentType"/>
    >
    > <xsd:complexType name="contentType">
    > <xsd:sequence>
    > <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    > <xsd:element minOccurs="1" name="text16" type="text16"/>
    > <xsd:element name="textarea13" type="textarea13"/>
    > <xsd:element minOccurs="0" name="binaryobject3"
    > type="binaryobject3"/>
    > </xsd:sequence>
    > </xsd:complexType>
    >
    > <xsd:simpleType name="text16">
    > <xsd:restriction base="xsd:string"/>
    > </xsd:simpleType>
    >
    > <xsd:simpleType name="textarea13">
    > <xsd:restriction base="xsd:string">
    > <xsd:minLength value="1"/>
    > </xsd:restriction>
    > </xsd:simpleType>
    >
    > <xsd:complexType name="binaryobject3">
    > <xsd:attribute name="filename"/>
    > </xsd:complexType>
    >
    > <xsd:complexType name="metainfo">
    > <xsd:sequence>
    > <xsd:any maxOccurs="unbounded" minOccurs="0"
    > processContents="skip"/>
    > </xsd:sequence>
    > <xsd:anyAttribute processContents="skip"/>
    > </xsd:complexType>
    >
    > </xsd:schema>
    >
    > output these messages:
    >
    > cvc-complex-type.2.4.a: Invalid content was found starting with
    > element 'textarea13'.
    > One of '{metainfo, text16}' is expected.
    > -------------^
    >
    > This message seems to me a little wrong, given
    >
    > <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    > ----------------------------------------^
    >
    > Perhaps I'm missing something, but as far as I understood, if this
    > atribute value is set to 0 the element is *optional*, thus can't figure
    > why xerces doesn't discriminate and report "one of those is expected".
    >
    > I would expect it to report only about the mandatory element(s)
    > missing, and not the whole sequence...
    >
    > I googled this but found nothing. Am I missing something?
    >
    > The other messages are just as expected...
    >
    > cvc-minLength-valid: Value '' with length = '0' is not facet-valid with
    > respect to minLength '1' for type 'textarea13'.
    > cvc-type.3.1.3: The value '' of element 'textarea13' is not valid.
    >
    > Thanks
    >
    > marcello stillitano
     
    George Bina, Jan 24, 2007
    #2
    1. Advertising

  3. wrote:

    > validating this XML:
    >
    > <Content4>
    > <textarea13></textarea13>
    > <binaryobject3></binaryobject3>
    > </Content4>
    >
    > against this schema:
    >
    > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    > xmlns:fo="http://www.w3.org/1999/XSL/Format">
    > <xsd:element name="Content4" type="contentType"/>
    >
    > <xsd:complexType name="contentType">
    > <xsd:sequence>
    > <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    > <xsd:element minOccurs="1" name="text16" type="text16"/>

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^

    Where is the text16 element for that you specify minOccurs="1"?

    > <xsd:element name="textarea13" type="textarea13"/>


    > output these messages:
    >
    > cvc-complex-type.2.4.a: Invalid content was found starting with
    > element 'textarea13'.
    > One of '{metainfo, text16}' is expected.
    > -------------^
    >
    > This message seems to me a little wrong, given
    >
    > <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    > ----------------------------------------^
    >
    > Perhaps I'm missing something, but as far as I understood, if this
    > atribute value is set to 0 the element is *optional*, thus can't figure
    > why xerces doesn't discriminate and report "one of those is expected".


    The parser only knows that metainfo is possible and that text16 is
    mandatory in the sequence so it tells you what might appear before the
    textarea13 element.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jan 24, 2007
    #3
  4. Guest

    On 24 Gen, 14:28, Martin Honnen <> wrote:
    > wrote:
    > > validating this XML:

    >
    > > <Content4>
    > > <textarea13></textarea13>
    > > <binaryobject3></binaryobject3>
    > > </Content4>

    >
    > > against this schema:

    >
    > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    > > xmlns:fo="http://www.w3.org/1999/XSL/Format">
    > > <xsd:element name="Content4" type="contentType"/>

    >
    > > <xsd:complexType name="contentType">
    > > <xsd:sequence>
    > > <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    > > <xsd:element minOccurs="1" name="text16" type="text16"/> ^^^^^^^^^^^^^^^^^^^^^^^^^^^

    >
    > Where is the text16 element for that you specify minOccurs="1"?
    >


    that is the point, I would expect a message for text16 *only*


    >
    >
    >
    > > <xsd:element name="textarea13" type="textarea13"/>
    > > output these messages:

    >
    > > cvc-complex-type.2.4.a: Invalid content was found starting with
    > > element 'textarea13'.
    > > One of '{metainfo, text16}' is expected.
    > > -------------^

    >
    > > This message seems to me a little wrong, given

    >
    > > <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    > > ----------------------------------------^

    >
    > > Perhaps I'm missing something, but as far as I understood, if this
    > > atribute value is set to 0 the element is *optional*, thus can't figure
    > > why xerces doesn't discriminate and report "one of those is expected".The parser only knows that metainfo is possible and that text16 is

    > mandatory in the sequence so it tells you what might appear before the
    > textarea13 element.
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/- Nascondi testo tra virgolette -- Mostra testo tra virgolette -- Nascondi testo tra virgolette -- Mostra testo tra virgolette -
     
    , Jan 24, 2007
    #4
  5. wrote:

    > that is the point, I would expect a message for text16 *only*


    I don't see anything wrong, if you had maxOccurs="0" on metainfo then it
    would not be possible but with the schema you have presented the
    sequence before textarea13 could have a metainfo element occuring once.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jan 24, 2007
    #5
  6. Guest

    Hi,

    I'm not sure if google posted my reply so I'll post again...

    My understanding of "minOccurs" set to 0 is that the element in the
    sequence colud be present or could be not , hence I would expect the
    validation not to mention it.

    Suppose to have a schema with a sequence of, say, twelve element in
    wich only one of them is mandatory, once I validate some xml with no
    elemet at all against it I get a message like "in your sequence one of
    this twelve element is needed"

    Perhaps returning a message like "look, in your sequence this mandatory
    element is missing" isn't Xerces job, but that is what I would expect.

    I'm using schema to server validate some values, and being able to tell
    *exactly* what of those is not conformant with the schema iteslf I
    found to be a generally well accomplished task with Xerces, but not in
    this case.

    Thanks

    ciao

    marcello stillitano

    On 24 Gen, 14:21, "George Bina" <> wrote:
    > Hi,
    >
    > Xerces does not tell you that you *must* enter metainfo, it just says
    > that it expects to find one of those elements at that position in the
    > document.
    >
    > Best Regards,
    > George
    > ---------------------------------------------------------------------
    > George Cristian Bina
    > <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debuggerhttp://www.oxygenxml.com
    >
    > On Jan 24, 1:07 pm, wrote:
    >
    >
    >
    > > Hi,

    >
    > > I am trying to use schema for server side validation using xerces to
    > > catch the validation errors.

    >
    > > validating this XML:

    >
    > > <Content4>
    > > <textarea13></textarea13>
    > > <binaryobject3></binaryobject3>
    > > </Content4>

    >
    > > against this schema:

    >
    > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    > > xmlns:fo="http://www.w3.org/1999/XSL/Format">
    > > <xsd:element name="Content4" type="contentType"/>

    >
    > > <xsd:complexType name="contentType">
    > > <xsd:sequence>
    > > <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    > > <xsd:element minOccurs="1" name="text16" type="text16"/>
    > > <xsd:element name="textarea13" type="textarea13"/>
    > > <xsd:element minOccurs="0" name="binaryobject3"
    > > type="binaryobject3"/>
    > > </xsd:sequence>
    > > </xsd:complexType>

    >
    > > <xsd:simpleType name="text16">
    > > <xsd:restriction base="xsd:string"/>
    > > </xsd:simpleType>

    >
    > > <xsd:simpleType name="textarea13">
    > > <xsd:restriction base="xsd:string">
    > > <xsd:minLength value="1"/>
    > > </xsd:restriction>
    > > </xsd:simpleType>

    >
    > > <xsd:complexType name="binaryobject3">
    > > <xsd:attribute name="filename"/>
    > > </xsd:complexType>

    >
    > > <xsd:complexType name="metainfo">
    > > <xsd:sequence>
    > > <xsd:any maxOccurs="unbounded" minOccurs="0"
    > > processContents="skip"/>
    > > </xsd:sequence>
    > > <xsd:anyAttribute processContents="skip"/>
    > > </xsd:complexType>

    >
    > > </xsd:schema>

    >
    > > output these messages:

    >
    > > cvc-complex-type.2.4.a: Invalid content was found starting with
    > > element 'textarea13'.
    > > One of '{metainfo, text16}' is expected.
    > > -------------^

    >
    > > This message seems to me a little wrong, given

    >
    > > <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    > > ----------------------------------------^

    >
    > > Perhaps I'm missing something, but as far as I understood, if this
    > > atribute value is set to 0 the element is *optional*, thus can't figure
    > > why xerces doesn't discriminate and report "one of those is expected".

    >
    > > I would expect it to report only about the mandatory element(s)
    > > missing, and not the whole sequence...

    >
    > > I googled this but found nothing. Am I missing something?

    >
    > > The other messages are just as expected...

    >
    > > cvc-minLength-valid: Value '' with length = '0' is not facet-valid with
    > > respect to minLength '1' for type 'textarea13'.
    > > cvc-type.3.1.3: The value '' of element 'textarea13' is not valid.

    >
    > > Thanks

    >
    > > marcello stillitano- Nascondi testo tra virgolette -- Mostra testo tra virgolette -
     
    , Jan 24, 2007
    #6
  7. Guest

    I answered in my reply to George Bina

    thanks

    marcello stillitano

    On 24 Gen, 17:35, Martin Honnen <> wrote:
    > wrote:
    > > that is the point, I would expect a message for text16 *only*I don't see anything wrong, if you had maxOccurs="0" on metainfo then it

    > would not be possible but with the schema you have presented the
    > sequence before textarea13 could have a metainfo element occuring once.
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/
     
    , Jan 24, 2007
    #7
  8. Guest

    [I messed with the reply option replying you privately, so I'll repost
    all the mailing here. Sorry for that!]

    Hi George,

    >No, that is not correct, look again, the message points you clearly that
    >the wrong element is textarea13, see: "Invalid content was found
    >starting with element 'textarea13'." and the error location info point
    >you also to the textarea13 element.


    well, validating this xml:

    <Content4>
    <textarea13></textarea13>
    <binaryobject3></binaryobject3>
    </Content4>

    against this schema:

    <xsd:element name="Content4" type="contentType"/>
    <xsd:complexType name="contentType">
    <xsd:sequence>
    <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    <xsd:element minOccurs="1" name="text16" type="text16"/>
    <xsd:element name="textarea13" type="textarea13"/>
    <xsd:element minOccurs="0" name="binaryobject3"
    type="binaryobject3"/>
    </xsd:sequence>
    </xsd:complexType>
    ....follow definitions...[2]

    I get this message:

    cvc-complex-type.2.4.a: Invalid content was found starting with
    element 'textarea13'.
    -------------^
    It's fine by Xerces to acknoledge me of that, but it's a bit
    redundant[1].

    One of '{metainfo, text16}' is expected.
    -------------^
    While here it is not discriminating at all between the missing
    mandatory element and the optional ones... and BTW why binaryobject3
    isn't in the list? How could I find out what of the mandatory elements
    is missing?

    If I have to acknowledge an user like "you did not provide these
    *mandatory* informations, please fill *these* fields and submit again"
    Where do I get from that message *only* the mandatory elements needed?


    [1] the rest of the message:
    cvc-minLength-valid: Value '' with length = '0' is not facet-valid
    with respect to minLength '1' for type 'textarea13'.
    cvc-type.3.1.3: The value '' of element 'textarea13' is not valid.

    >However, if you feel very
    >strongly that this is wrong then I would suggest opening a request for
    >enhancement on Xerces Jira and the Xerces developers will have their
    >take on this issue.


    I'm saying it could be done a bit better *but* from my very point of
    view... I'm not very sure were to submit this request, is it that the
    right place? : http://forum.java.sun.com/thread.jspa?
    forumID=17&threadID=564284

    If is not and if you know where, could you please provide me the where
    to post my doubts / requests?

    Thank you very much!

    ciao

    marcello

    Hi Marcello,

    > Sorry but I still don't get the point of such message... It gives

    me not
    > actually any clue of the "wrong" elements, it just brings to my
    > attention that "something is wrong there".



    No, that is not correct, look again, the message points you clearly
    that
    the wrong element is textarea13, see: "Invalid content was found
    starting with element 'textarea13'." and the error location info point
    you also to the textarea13 element.

    IMO Xerces gives a good error message and as a user I prefer this
    message instead of something as you propose. However, if you feel very
    strongly that this is wrong then I would suggest opening a request for
    enhancement on Xerces Jira and the Xerces developers will have their
    take on this issue.


    > p.s. Why don't we keep this discussion public? I googled

    extensively
    > this topic and found really few, guess other devs could find those
    > informations very useful!



    I did not made the discussion private, you did, you replied to me
    personally - I always use reply to all and I remember I double checked
    in this case if you sent the message only to me or also to the list.

    Fell free to post our discussion back to the list.


    Best Regards,
    George
    ---------------------------------------------------------------------
    George Cristian Bina

    <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
    http://www.oxygenxml.com



    - Show quoted text -
    marcello stillitano wrote:
    > Hi George,
    >
    > Sorry for the great delay of this the reply but I rarely use this account..
    >
    > Xerces already gives in facet validation two messages (each one related
    > to the relative specification) so it could keeping giving the
    > same message AND another one enlisting-highlighting just the mandatory
    > ones, no matter of their position in the sequence, because the same
    > message is also displayied using the "all" statament, thus no
    > specific order is given.
    >
    > My utopian message would be very cheap to achieve, that would just tell
    > me that some of the expected mandatory elements are missing, no matter
    > their position in the sequence, just: "look, this schema expect those
    > elements to be in place because their minoccurs attribute is greater
    > than zero, those others instead are optionals"
    >
    > I know schema is more a "structure" validator than a "content"
    > one, but in this specific case I can't onestly see the use of that
    > message...
    >
    > "Imagine that you edit the document. It is better to get in the error
    > message all the elements that can be inserted at that position..."
    >
    > Sorry but I still don't get the point of such message... It gives me not
    > actually any clue of the "wrong" elements, it just brings to my
    > attention that "something is wrong there".
    >
    > thanks and excuse me again for the delay!
    >
    > ciao,
    >
    > Marcello
    >
    > p.s. Why don't we keep this discussion public? I googled extensively
    > this topic and found really few, guess other devs could find those
    > informations very useful!
    >
    >
    > On 1/24/07, *George Cristian Bina* <


    > <mailto:>> wrote:
    >
    > Hi Marcello,
    >
    > If the error message would have contained only mandatory elements then
    > people will complain why the parser says so, because the element x
    > which
    > is optional is perfectly ok at that position so the parser should expect
    > to see that as well as the mandatory elements.
    > The perfect but utopian message would be to enumerate all the possible
    > combinations that can appear at that location. That's clearly
    > practically impossible due to the very large number of possible
    > combinations so Xerces just shows all the elements that can be inserted
    > further to create valid content.
    > Imagine that you edit the document. It is better to get in the error
    > message all the elements that can be inserted at that position instead
    > of getting only the required elements as in that way you have more
    > information how to continue your editing, what elements you can insert
    > there and keep the document valid.
    >
    > Regards,
    > George
    > ---------------------------------------------------------------------
    > George Cristian Bina
    > <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
    > http://www.oxygenxml.com
    >
    >


    > <mailto:> wrote:
    > > Hi,
    > >
    > > My point is, doesn't "minOccurs" means "this element *may* exists in
    > > that position but also may not" ?
    > >
    > > Perhaps I'm wrong about that, but in a sequence of, say, ten elements
    > > or more a message saying that one in the whole sequence is expected
    > > ain't very useful.
    > >
    > > I would expect the validation to skip on the not mandatory elements,
    > > but, once again, perhaps mine is wrong expectation.
    > >
    > > Thanks for answering!
    > >
    > > ciao
    > >
    > > marcello
    > >


    On 24 Gen, 14:21, "George Bina" <> wrote:
    > Hi,
    >
    > Xerces does not tell you that you *must* enter metainfo, it just says
    > that it expects to find one of those elements at that position in the
    > document.
    >
    > Best Regards,
    > George
    > ---------------------------------------------------------------------
    > George Cristian Bina
    > <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debuggerhttp://www.oxygenxml.com
    >
    > On Jan 24, 1:07 pm, wrote:
    >
    >
    >
    > > Hi,

    >
    > > I am trying to use schema for server side validation using xerces to
    > > catch the validation errors.

    >
    > > validating this XML:

    >
    > > <Content4>
    > > <textarea13></textarea13>
    > > <binaryobject3></binaryobject3>
    > > </Content4>

    >
    > > against this schema:

    >
    > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    > > xmlns:fo="http://www.w3.org/1999/XSL/Format">
    > > <xsd:element name="Content4" type="contentType"/>

    >
    > > <xsd:complexType name="contentType">
    > > <xsd:sequence>
    > > <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    > > <xsd:element minOccurs="1" name="text16" type="text16"/>
    > > <xsd:element name="textarea13" type="textarea13"/>
    > > <xsd:element minOccurs="0" name="binaryobject3"
    > > type="binaryobject3"/>
    > > </xsd:sequence>
    > > </xsd:complexType>

    >
    > > <xsd:simpleType name="text16">
    > > <xsd:restriction base="xsd:string"/>
    > > </xsd:simpleType>

    >
    > > <xsd:simpleType name="textarea13">
    > > <xsd:restriction base="xsd:string">
    > > <xsd:minLength value="1"/>
    > > </xsd:restriction>
    > > </xsd:simpleType>

    >
    > > <xsd:complexType name="binaryobject3">
    > > <xsd:attribute name="filename"/>
    > > </xsd:complexType>

    >
    > > <xsd:complexType name="metainfo">
    > > <xsd:sequence>
    > > <xsd:any maxOccurs="unbounded" minOccurs="0"
    > > processContents="skip"/>
    > > </xsd:sequence>
    > > <xsd:anyAttribute processContents="skip"/>
    > > </xsd:complexType>

    >
    > > </xsd:schema>

    >
    > > output these messages:

    >
    > > cvc-complex-type.2.4.a: Invalid content was found starting with
    > > element 'textarea13'.
    > > One of '{metainfo, text16}' is expected.
    > > -------------^

    >
    > > This message seems to me a little wrong, given

    >
    > > <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    > > ----------------------------------------^

    >
    > > Perhaps I'm missing something, but as far as I understood, if this
    > > atribute value is set to 0 the element is *optional*, thus can't figure
    > > why xerces doesn't discriminate and report "one of those is expected".

    >
    > > I would expect it to report only about the mandatory element(s)
    > > missing, and not the whole sequence...

    >
    > > I googled this but found nothing. Am I missing something?

    >
    > > The other messages are just as expected...

    >
    > > cvc-minLength-valid: Value '' with length = '0' is not facet-valid with
    > > respect to minLength '1' for type 'textarea13'.
    > > cvc-type.3.1.3: The value '' of element 'textarea13' is not valid.

    >
    > > Thanks

    >
    > > marcello stillitano- Nascondi testo tra virgolette -- Mostra testo tra virgolette -
     
    , Jan 29, 2007
    #8
  9. George Bina Guest

    Hi Marcelo,

    > One of '{metainfo, text16}' is expected.
    > -------------^
    > While here it is not discriminating at all between the missing
    > mandatory element and the optional ones... and BTW why binaryobject3
    > isn't in the list? How could I find out what of the mandatory elements
    > is missing?


    The binaryobject3 is not allowed at that position in the document, in
    the same way as textare13 is not allowed, that is why the element is
    not in the list.

    > I'm not very sure were to submit this request, is it that the
    > right place? :http://forum.java.sun.com/thread.jspa?
    > forumID=17&threadID=564284
    >
    > If is not and if you know where, could you please provide me the where
    > to post my doubts / requests?


    See
    http://xerces.apache.org/xerces2-j/jira.html
    I suggest you should write first to the
    list as the page suggests.

    Regards,
    George
    ---------------------------------------------------------------------
    George Cristian Bina
    <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
    http://www.oxygenxml.com

    On Jan 29, 3:10 pm, wrote:
    > [I messed with the reply option replying you privately, so I'll repost
    > all the mailing here. Sorry for that!]
    >
    > Hi George,
    >
    > >No, that is not correct, look again, the message points you clearly that
    > >the wrong element is textarea13, see: "Invalid content was found
    > >starting with element 'textarea13'." and the error location info point
    > >you also to the textarea13 element.well, validating this xml:

    >
    > <Content4>
    > <textarea13></textarea13>
    > <binaryobject3></binaryobject3>
    > </Content4>
    >
    > against this schema:
    >
    > <xsd:element name="Content4" type="contentType"/>
    > <xsd:complexType name="contentType">
    > <xsd:sequence>
    > <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    > <xsd:element minOccurs="1" name="text16" type="text16"/>
    > <xsd:element name="textarea13" type="textarea13"/>
    > <xsd:element minOccurs="0" name="binaryobject3"
    > type="binaryobject3"/>
    > </xsd:sequence>
    > </xsd:complexType>
    > ...follow definitions...[2]
    >
    > I get this message:
    >
    > cvc-complex-type.2.4.a: Invalid content was found starting with
    > element 'textarea13'.
    > -------------^
    > It's fine by Xerces to acknoledge me of that, but it's a bit
    > redundant[1].
    >
    > One of '{metainfo, text16}' is expected.
    > -------------^
    > While here it is not discriminating at all between the missing
    > mandatory element and the optional ones... and BTW why binaryobject3
    > isn't in the list? How could I find out what of the mandatory elements
    > is missing?
    >
    > If I have to acknowledge an user like "you did not provide these
    > *mandatory* informations, please fill *these* fields and submit again"
    > Where do I get from that message *only* the mandatory elements needed?
    >
    > [1] the rest of the message:
    > cvc-minLength-valid: Value '' with length = '0' is not facet-valid
    > with respect to minLength '1' for type 'textarea13'.
    > cvc-type.3.1.3: The value '' of element 'textarea13' is not valid.
    >
    > >However, if you feel very
    > >strongly that this is wrong then I would suggest opening a request for
    > >enhancement on Xerces Jira and the Xerces developers will have their
    > >take on this issue.I'm saying it could be done a bit better *but* from my very point of

    > view... I'm not very sure were to submit this request, is it that the
    > right place? :http://forum.java.sun.com/thread.jspa?
    > forumID=17&threadID=564284
    >
    > If is not and if you know where, could you please provide me the where
    > to post my doubts / requests?
    >
    > Thank you very much!
    >
    > ciao
    >
    > marcello
    >
    > Hi Marcello,
    >
    > > Sorry but I still don't get the point of such message... It gives

    > me not
    > > actually any clue of the "wrong" elements, it just brings to my
    > > attention that "something is wrong there".

    >
    > No, that is not correct, look again, the message points you clearly
    > that
    > the wrong element is textarea13, see: "Invalid content was found
    > starting with element 'textarea13'." and the error location info point
    > you also to the textarea13 element.
    >
    > IMO Xerces gives a good error message and as a user I prefer this
    > message instead of something as you propose. However, if you feel very
    > strongly that this is wrong then I would suggest opening a request for
    > enhancement on Xerces Jira and the Xerces developers will have their
    > take on this issue.
    >
    > > p.s. Why don't we keep this discussion public? I googled

    > extensively
    > > this topic and found really few, guess other devs could find those
    > > informations very useful!

    >
    > I did not made the discussion private, you did, you replied to me
    > personally - I always use reply to all and I remember I double checked
    > in this case if you sent the message only to me or also to the list.
    >
    > Fell free to post our discussion back to the list.
    >
    > Best Regards,
    > George
    > ---------------------------------------------------------------------
    > George Cristian Bina
    >
    > <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debuggerhttp://www.oxygenxml.com
    >
    > - Show quoted text -
    >
    >
    >
    > marcello stillitano wrote:
    > > Hi George,

    >
    > > Sorry for the great delay of this the reply but I rarely use this account..

    >
    > > Xerces already gives in facet validation two messages (each one related
    > > to the relative specification) so it could keeping giving the
    > > same message AND another one enlisting-highlighting just the mandatory
    > > ones, no matter of their position in the sequence, because the same
    > > message is also displayied using the "all" statament, thus no
    > > specific order is given.

    >
    > > My utopian message would be very cheap to achieve, that would just tell
    > > me that some of the expected mandatory elements are missing, no matter
    > > their position in the sequence, just: "look, this schema expect those
    > > elements to be in place because their minoccurs attribute is greater
    > > than zero, those others instead are optionals"

    >
    > > I know schema is more a "structure" validator than a "content"
    > > one, but in this specific case I can't onestly see the use of that
    > > message...

    >
    > > "Imagine that you edit the document. It is better to get in the error
    > > message all the elements that can be inserted at that position..."

    >
    > > Sorry but I still don't get the point of such message... It gives me not
    > > actually any clue of the "wrong" elements, it just brings to my
    > > attention that "something is wrong there".

    >
    > > thanks and excuse me again for the delay!

    >
    > > ciao,

    >
    > > Marcello

    >
    > > p.s. Why don't we keep this discussion public? I googled extensively
    > > this topic and found really few, guess other devs could find those
    > > informations very useful!

    >
    > > On 1/24/07, *George Cristian Bina* <
    > > <mailto:>> wrote:

    >
    > > Hi Marcello,

    >
    > > If the error message would have contained only mandatory elements then
    > > people will complain why the parser says so, because the element x
    > > which
    > > is optional is perfectly ok at that position so the parser should expect
    > > to see that as well as the mandatory elements.
    > > The perfect but utopian message would be to enumerate all the possible
    > > combinations that can appear at that location. That's clearly
    > > practically impossible due to the very large number of possible
    > > combinations so Xerces just shows all the elements that can be inserted
    > > further to create valid content.
    > > Imagine that you edit the document. It is better to get in the error
    > > message all the elements that can be inserted at that position instead
    > > of getting only the required elements as in that way you have more
    > > information how to continue your editing, what elements you can insert
    > > there and keep the document valid.

    >
    > > Regards,
    > > George
    > > ---------------------------------------------------------------------
    > > George Cristian Bina
    > > <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
    > > http://www.oxygenxml.com

    >
    > > <mailto:> wrote:
    > > > Hi,

    >
    > > > My point is, doesn't "minOccurs" means "this element *may* exists in
    > > > that position but also may not" ?

    >
    > > > Perhaps I'm wrong about that, but in a sequence of, say, ten elements
    > > > or more a message saying that one in the whole sequence is expected
    > > > ain't very useful.

    >
    > > > I would expect the validation to skip on the not mandatory elements,
    > > > but, once again, perhaps mine is wrong expectation.

    >
    > > > Thanks for answering!

    >
    > > > ciao

    >
    > > > marcelloOn 24 Gen, 14:21, "George Bina" <> wrote:

    >
    > > Hi,

    >
    > > Xerces does not tell you that you *must* enter metainfo, it just says
    > > that it expects to find one of those elements at that position in the
    > > document.

    >
    > > Best Regards,
    > > George
    > > ---------------------------------------------------------------------
    > > George Cristian Bina
    > > <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debuggerhttp://www.oxygenxml.com

    >
    > > On Jan 24, 1:07 pm, wrote:

    >
    > > > Hi,

    >
    > > > I am trying to use schema for server side validation using xerces to
    > > > catch the validation errors.

    >
    > > > validating this XML:

    >
    > > > <Content4>
    > > > <textarea13></textarea13>
    > > > <binaryobject3></binaryobject3>
    > > > </Content4>

    >
    > > > against this schema:

    >
    > > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    > > > xmlns:fo="http://www.w3.org/1999/XSL/Format">
    > > > <xsd:element name="Content4" type="contentType"/>

    >
    > > > <xsd:complexType name="contentType">
    > > > <xsd:sequence>
    > > > <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    > > > <xsd:element minOccurs="1" name="text16" type="text16"/>
    > > > <xsd:element name="textarea13" type="textarea13"/>
    > > > <xsd:element minOccurs="0" name="binaryobject3"
    > > > type="binaryobject3"/>
    > > > </xsd:sequence>
    > > > </xsd:complexType>

    >
    > > > <xsd:simpleType name="text16">
    > > > <xsd:restriction base="xsd:string"/>
    > > > </xsd:simpleType>

    >
    > > > <xsd:simpleType name="textarea13">
    > > > <xsd:restriction base="xsd:string">
    > > > <xsd:minLength value="1"/>
    > > > </xsd:restriction>
    > > > </xsd:simpleType>

    >
    > > > <xsd:complexType name="binaryobject3">
    > > > <xsd:attribute name="filename"/>
    > > > </xsd:complexType>

    >
    > > > <xsd:complexType name="metainfo">
    > > > <xsd:sequence>
    > > > <xsd:any maxOccurs="unbounded" minOccurs="0"
    > > > processContents="skip"/>
    > > > </xsd:sequence>
    > > > <xsd:anyAttribute processContents="skip"/>
    > > > </xsd:complexType>

    >
    > > > </xsd:schema>

    >
    > > > output these messages:

    >
    > > > cvc-complex-type.2.4.a: Invalid content was found starting with
    > > > element 'textarea13'.
    > > > One of '{metainfo, text16}' is expected.
    > > > -------------^

    >
    > > > This message seems to me a little wrong, given

    >
    > > > <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    > > > ----------------------------------------^

    >
    > > > Perhaps I'm missing something, but as far as I understood, if this
    > > > atribute value is set to 0 the element is *optional*, thus can't figure
    > > > why xerces doesn't discriminate and report "one of those is expected".

    >
    > > > I would expect it to report only about the mandatory element(s)...

    >
    > read more ยป
     
    George Bina, Jan 29, 2007
    #9
  10. Guest

    thanks!

    ciao

    marcello

    On 29 Gen, 15:43, "George Bina" <> wrote:
    > Hi Marcelo,
    >
    > > One of '{metainfo, text16}' is expected.
    > > -------------^
    > > While here it is not discriminating at all between the missing
    > > mandatory element and the optional ones... and BTW why binaryobject3
    > > isn't in the list? How could I find out what of the mandatory elements
    > > is missing?The binaryobject3 is not allowed at that position in the document, in

    > the same way as textare13 is not allowed, that is why the element is
    > not in the list.
    >
    > > I'm not very sure were to submit this request, is it that the
    > > right place? :http://forum.java.sun.com/thread.jspa?
    > > forumID=17&threadID=564284

    >
    > > If is not and if you know where, could you please provide me the where
    > > to post my doubts / requests?Seehttp://xerces.apache.org/xerces2-j/jira.html

    > I suggest you should write first to the
    > list as the page suggests.
    >
    > Regards,
    > George
    > ---------------------------------------------------------------------
    > George Cristian Bina
    > <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debuggerhttp://www.oxygenxml.com
    >
    > On Jan 29, 3:10 pm, wrote:
    >
    >
    >
    > > [I messed with the reply option replying you privately, so I'll repost
    > > all the mailing here. Sorry for that!]

    >
    > > Hi George,

    >
    > > >No, that is not correct, look again, the message points you clearly that
    > > >the wrong element is textarea13, see: "Invalid content was found
    > > >starting with element 'textarea13'." and the error location info point
    > > >you also to the textarea13 element.well, validating this xml:

    >
    > > <Content4>
    > > <textarea13></textarea13>
    > > <binaryobject3></binaryobject3>
    > > </Content4>

    >
    > > against this schema:

    >
    > > <xsd:element name="Content4" type="contentType"/>
    > > <xsd:complexType name="contentType">
    > > <xsd:sequence>
    > > <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    > > <xsd:element minOccurs="1" name="text16" type="text16"/>
    > > <xsd:element name="textarea13" type="textarea13"/>
    > > <xsd:element minOccurs="0" name="binaryobject3"
    > > type="binaryobject3"/>
    > > </xsd:sequence>
    > > </xsd:complexType>
    > > ...follow definitions...[2]

    >
    > > I get this message:

    >
    > > cvc-complex-type.2.4.a: Invalid content was found starting with
    > > element 'textarea13'.
    > > -------------^
    > > It's fine by Xerces to acknoledge me of that, but it's a bit
    > > redundant[1].

    >
    > > One of '{metainfo, text16}' is expected.
    > > -------------^
    > > While here it is not discriminating at all between the missing
    > > mandatory element and the optional ones... and BTW why binaryobject3
    > > isn't in the list? How could I find out what of the mandatory elements
    > > is missing?

    >
    > > If I have to acknowledge an user like "you did not provide these
    > > *mandatory* informations, please fill *these* fields and submit again"
    > > Where do I get from that message *only* the mandatory elements needed?

    >
    > > [1] the rest of the message:
    > > cvc-minLength-valid: Value '' with length = '0' is not facet-valid
    > > with respect to minLength '1' for type 'textarea13'.
    > > cvc-type.3.1.3: The value '' of element 'textarea13' is not valid.

    >
    > > >However, if you feel very
    > > >strongly that this is wrong then I would suggest opening a request for
    > > >enhancement on Xerces Jira and the Xerces developers will have their
    > > >take on this issue.I'm saying it could be done a bit better *but* from my very point of

    > > view... I'm not very sure were to submit this request, is it that the
    > > right place? :http://forum.java.sun.com/thread.jspa?
    > > forumID=17&threadID=564284

    >
    > > If is not and if you know where, could you please provide me the where
    > > to post my doubts / requests?

    >
    > > Thank you very much!

    >
    > > ciao

    >
    > > marcello

    >
    > > Hi Marcello,

    >
    > > > Sorry but I still don't get the point of such message... It gives

    > > me not
    > > > actually any clue of the "wrong" elements, it just brings to my
    > > > attention that "something is wrong there".

    >
    > > No, that is not correct, look again, the message points you clearly
    > > that
    > > the wrong element is textarea13, see: "Invalid content was found
    > > starting with element 'textarea13'." and the error location info point
    > > you also to the textarea13 element.

    >
    > > IMO Xerces gives a good error message and as a user I prefer this
    > > message instead of something as you propose. However, if you feel very
    > > strongly that this is wrong then I would suggest opening a request for
    > > enhancement on Xerces Jira and the Xerces developers will have their
    > > take on this issue.

    >
    > > > p.s. Why don't we keep this discussion public? I googled

    > > extensively
    > > > this topic and found really few, guess other devs could find those
    > > > informations very useful!

    >
    > > I did not made the discussion private, you did, you replied to me
    > > personally - I always use reply to all and I remember I double checked
    > > in this case if you sent the message only to me or also to the list.

    >
    > > Fell free to post our discussion back to the list.

    >
    > > Best Regards,
    > > George
    > > ---------------------------------------------------------------------
    > > George Cristian Bina

    >
    > > <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debuggerhttp://www.oxygenxml.com

    >
    > > - Show quoted text -

    >
    > > marcello stillitano wrote:
    > > > Hi George,

    >
    > > > Sorry for the great delay of this the reply but I rarely use this account..

    >
    > > > Xerces already gives in facet validation two messages (each one related
    > > > to the relative specification) so it could keeping giving the
    > > > same message AND another one enlisting-highlighting just the mandatory
    > > > ones, no matter of their position in the sequence, because the same
    > > > message is also displayied using the "all" statament, thus no
    > > > specific order is given.

    >
    > > > My utopian message would be very cheap to achieve, that would just tell
    > > > me that some of the expected mandatory elements are missing, no matter
    > > > their position in the sequence, just: "look, this schema expect those
    > > > elements to be in place because their minoccurs attribute is greater
    > > > than zero, those others instead are optionals"

    >
    > > > I know schema is more a "structure" validator than a "content"
    > > > one, but in this specific case I can't onestly see the use of that
    > > > message...

    >
    > > > "Imagine that you edit the document. It is better to get in the error
    > > > message all the elements that can be inserted at that position..."

    >
    > > > Sorry but I still don't get the point of such message... It gives me not
    > > > actually any clue of the "wrong" elements, it just brings to my
    > > > attention that "something is wrong there".

    >
    > > > thanks and excuse me again for the delay!

    >
    > > > ciao,

    >
    > > > Marcello

    >
    > > > p.s. Why don't we keep this discussion public? I googled extensively
    > > > this topic and found really few, guess other devs could find those
    > > > informations very useful!

    >
    > > > On 1/24/07, *George Cristian Bina* <
    > > > <mailto:>> wrote:

    >
    > > > Hi Marcello,

    >
    > > > If the error message would have contained only mandatory elements then
    > > > people will complain why the parser says so, because the element x
    > > > which
    > > > is optional is perfectly ok at that position so the parser should expect
    > > > to see that as well as the mandatory elements.
    > > > The perfect but utopian message would be to enumerate all the possible
    > > > combinations that can appear at that location. That's clearly
    > > > practically impossible due to the very large number of possible
    > > > combinations so Xerces just shows all the elements that can be inserted
    > > > further to create valid content.
    > > > Imagine that you edit the document. It is better to get in the error
    > > > message all the elements that can be inserted at that position instead
    > > > of getting only the required elements as in that way you have more
    > > > information how to continue your editing, what elements you can insert
    > > > there and keep the document valid.

    >
    > > > Regards,
    > > > George
    > > > ---------------------------------------------------------------------
    > > > George Cristian Bina
    > > > <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
    > > > http://www.oxygenxml.com

    >
    > > > <mailto:> wrote:
    > > > > Hi,

    >
    > > > > My point is, doesn't "minOccurs" means "this element *may* exists in
    > > > > that position but also may not" ?

    >
    > > > > Perhaps I'm wrong about that, but in a sequence of, say, ten elements
    > > > > or more a message saying that one in the whole sequence is expected
    > > > > ain't very useful.

    >
    > > > > I would expect the validation to skip on the not mandatory elements,
    > > > > but, once again, perhaps mine is wrong expectation.

    >
    > > > > Thanks for answering!

    >
    > > > > ciao

    >
    > > > > marcelloOn 24 Gen, 14:21, "George Bina" <> wrote:

    >
    > > > Hi,

    >
    > > > Xerces does not tell you that you *must* enter metainfo, it just says
    > > > that it expects to find one of those elements at that position in the
    > > > document.

    >
    > > > Best Regards,
    > > > George
    > > > ---------------------------------------------------------------------
    > > > George Cristian Bina
    > > > <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debuggerhttp://www.oxygenxml.com

    >
    > > > On Jan 24, 1:07 pm, wrote:

    >
    > > > > Hi,

    >
    > > > > I am trying to use schema for server side validation using xerces to
    > > > > catch the validation errors.

    >
    > > > > validating this XML:

    >
    > > > > <Content4>
    > > > > <textarea13></textarea13>
    > > > > <binaryobject3></binaryobject3>
    > > > > </Content4>

    >
    > > > > against this schema:

    >
    > > > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    > > > > xmlns:fo="http://www.w3.org/1999/XSL/Format">
    > > > > <xsd:element name="Content4" type="contentType"/>

    >
    > > > > <xsd:complexType name="contentType">
    > > > > <xsd:sequence>
    > > > > <xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
    > > > > <xsd:element minOccurs="1" name="text16" type="text16"/>
    > > > > <xsd:element name="textarea13" type="textarea13"/>
    > > > > <xsd:element minOccurs="0" name="binaryobject3"...

    >
    > leggi tutto- Nascondi testo tra virgolette -- Mostra testo tra virgolette -
     
    , Jan 29, 2007
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ole Hedegaard

    Xerces schema validation

    Ole Hedegaard, Nov 25, 2003, in forum: Java
    Replies:
    2
    Views:
    957
    Esmond Pitt
    Nov 26, 2003
  2. Markus
    Replies:
    1
    Views:
    1,637
    Markus
    Nov 23, 2005
  3. Ole Hedegaard

    Xerces schema validation

    Ole Hedegaard, Nov 25, 2003, in forum: XML
    Replies:
    1
    Views:
    609
    Florian Deissenboeck
    Nov 27, 2003
  4. Olaf Meyer
    Replies:
    2
    Views:
    708
    Olaf Meyer
    Jan 15, 2004
  5. Grand Apeiron
    Replies:
    7
    Views:
    1,782
    Peter Flynn
    Jan 20, 2004
Loading...

Share This Page