[Xml-compile] Re: xs:choice question

DEIGNAN Ciaran C.DEIGNAN at rsd.com
Tue Sep 17 14:17:13 GMT 2013



Hi Mark,



(I saw on the list archive that you answered my mail, but our mail server must have eaten the reply.)



> Am I the only one who doesn't like the Russian Doll?

> http://www.oracle.com/technetwork/java/design-patterns-142138.html



In defence of our developers, the schema is generated dynamically because the data structure is user-defined.



> Have your tried

>    print $schema->template(PERL => "$yourns:contents");



I generated the template for the whole structure. For this extract it says



  # is an unnamed complex

  # is optional

  contents =>

  { # sequence of component



    # is an unnamed complex

    # occurs any number of times

    component =>

    [ { # choice of csRef



        # is an unnamed complex

        # is optional

        csRef =>

        { # sequence of csId, contentId



          # is a xs:string

          # Enum: cmis cmis-alfresco demo0 demo1 demo_no_logisitics

          #    demo_with_logisitics fld fld_zos jcr sp2010

          #    test.manual.enforce

          csId => "cmis",



          # is a xs:string

          contentId => "example", },





It does say that the choice is optional...





> So, you can say:

>    component => [

>      { cho_csRef => []

>        ...

>      }



I tried that, but it says:



error: no match for required block `cho_csRef' at node/contents/component



I tried with "csRef => {}", and it said:



error: required value for element `csId' missing at node/contents/component/csRef



I tried with "csRef => undef,", and it goes back to "no match ...".



Schema in attachment.



Ciaran



From: DEIGNAN Ciaran [mailto:C.DEIGNAN at rsd.com]
Sent: jeudi 12 septembre 2013 14:40
To: xml-compile at lists.scsys.co.uk<mailto:xml-compile at lists.scsys.co.uk>
Subject: [Xml-compile] xs:choice question



Hi Mark and list,



I'm not sure if this is a XML::Compile question or just proof that I need training on XML.



I have a schema that contains a section like this:



<xs:element minOccurs="0" name="contents">

<xs:complexType>

<xs:sequence>

<xs:element maxOccurs="unbounded" minOccurs="0" name="component">

<xs:complexType>

<xs:choice>

<xs:element minOccurs="0" name="csRef">

<xs:annotation>

<xs:documentation>This element can be used to referenced when the content is already

stored in a content repository.

In the case of uploading the content, it must not be present.

</xs:documentation>

</xs:annotation>

<xs:complexType>

<xs:sequence>

<xs:element name="csId" type="csIdType"/>

<xs:element name="contentId" type="xs:string"/>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:choice>





In perl I build a structure like this:



                               contents => {

                                               component => [

                                                               {

                                                                              csRef => { csId => 'fld', contentId => 'docid', },

                                                                              title => 'PerlTest',

                                                                              mimeType => 'text/plain',

                                                                              fileExtension => 'txt',

                                                                              lang => 'fr',

                                                               },

                                               ],





The above fragment will be converted to XML by XML::Compile::Schema. However if I don't specify the csRef, it refuses to convert to XML, and gives me the error



error: no match for required block `cho_csRef' at node/contents/component



The schema does say   minOccurs="0", so I don't know why I have to provide it.

However the xs:choice does seem required, so I understand the error.

Is the schema just bad ?



Thanks for any pointers,



Ciaran Deignan

RSD Technical Support


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/xml-compile/attachments/20130917/6143a039/attachment-0001.htm


More information about the Xml-compile mailing list