Dear monks,

i am using XML::LibXML::Schema to validate XML documents against XML schemas. Recently I come across a WSDL containing in types section more than one schema element. How can I combine those related schemas into one XML::LibXML::Schema object?

I simplified those schemas to following example:

<?xml version="1.0"?>
<s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"
  xmlns:s1="http://schemas.salwin-crm.com/2007/coreTypes"
  elementFormDefault="qualified"
  targetNamespace="http://schemas.salwin-crm.com/2007/webServices">
  <s:import namespace="http://schemas.salwin-crm.com/2007/coreTypes" />
  <s:element name="UploadResponse">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="1" maxOccurs="1" ref="s1:UploadResult"/>
      </s:sequence>
    </s:complexType>
  </s:element>
</s:schema>
<?xml version="1.0"?>
<s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"
  xmlns:s1="http://schemas.salwin-crm.com/2007/coreTypes"
  elementFormDefault="qualified"
  targetNamespace="http://schemas.salwin-crm.com/2007/coreTypes">
      <s:element name="UploadResult" nillable="true" type="s:string"/>
</s:schema>

Parsing the first schema separately via XML::LibXML::Schema->new('string' => $str) results in quite expectable error:

Element '{http://www.w3.org/2001/XMLSchema}element', 
attribute 'ref': The QName value 
'{http://schemas.salwin-crm.com/2007/coreTypes}UploadResult'
 does not resolve to a(n) element declaration. 

The only way I found so far is to store the second schema into file and supply s:import element with schemaLocation attribute pointing to this file. But this is an adhoc cumbersome solution. I hope that there is a cleaner and more systematic one.


In reply to Parsing more schemas at once with XML::LibXML::Schema by roman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.