0
votes

an extract of the xsd file:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           xmlns="http://www.derivatexxl.de/derivatexxl/v1.1" 
           targetNamespace="http://www.derivatexxl.de/derivatexxl/v1.1" 
           elementFormDefault="qualified" 
           attributeFormDefault="unqualified">
  <xs:include schemaLocation="derivatexxlTypes.xsd"/>
  <!-- Root -->
  <xs:element name="DERIVATEXXL">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="DELIVERY"/>
        <xs:element ref="GENERAL_INFORMATION" minOccurs="0"/>
        <xs:element ref="SENDER"/>
        <xs:element ref="ISSUER"/>
        <xs:element ref="PRODUCT" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

My code:

use warnings;
use strict;
use XML::Compile::Cache;
use XML::Compile::Util qw/pack_type/;

my $xsds = ['derivatexxlTypes.xsd', 'derivatexxl_110.xsd'];
my $schema = XML::Compile::Cache->new($xsds);
# This works, it prints all the available definitions
$schema->printIndex();
my $type = pack_type 'http://www.derivatexxl.de/derivatexxl/v1.1', 'DERIVATEXXL';
warn $schema->template('PERL' => $type);

I get this error message back: "regexp error : failed to compile: Expecting a char range"

If I change the last line to: warn $schema->template('PERL' => 'DERIVATEXXL');

I get the error: "error: cannot find element or attribute `DERIVATEXXL'"

To tell you the truth, I'm not sure if I just don't get it, or if XML::Compile can't work with these xsd files...

I'd be very grateful for any help.

Thank you.

1

1 Answers

0
votes

The error message "regexp error ..." suggests that the schema processor is objecting to a regular expression in the schema, which means the problem will be on an xsd:pattern element. The XSD schema document you show does not contain any pattern elements, so it would appear that the problem is in the schema document derivatexxlTypes.xsd.

The description of the problem ("Expecting a char range") suggests that the parser has found a left square bracket in the expression and thinks it has seen the beginning of a character range (which takes the form a-z or similar), but not the ending. Note that in XSD 1.0, unlike Perl, some processors are apt to have trouble with expressions like [a-zA-Z.-] -- if you want a hyphen in the character group, escape it: [a-zA-Z.\-].

The error message you get when you change your code looks to me like a secondary problem. You know already that the processor is not succeeding in compiling the schema, and when you ask it for a particular element in the schema it is not surprising that it cannot find the element: it couldn't compile the schema, so when it's looking for an element or attribute named DERIVATEXXL in the compiled schema, it's looking in an empty schema. (But I am not a user of XML::Compile; this is speculation.)