开发者

perl xml dom error

开发者 https://www.devze.com 2023-01-21 07:10 出处:网络
try.pl is a script that is trying to generate sample.xml which should validate against sample.xsd. I am getting some errors. Guide me if possible.

try.pl is a script that is trying to generate sample.xml which should validate against sample.xsd. I am getting some errors. Guide me if possible.

portion of sample.xsd

 <xs:element name="element1" maxOccurs="unbounded">
  <xs:complexType>
    <xs:SimpleContent>   <---- line number of error
      <xs:extension base="xs:token">
        <xs:attribute name="attrib1" typ开发者_如何学运维e="xs:token"/>
      </xs:extension>
    </xs:SimpleContent>
  </xs:complexType>
 </xs:element>

sample.xml should look:

<elements>
  <element1 attrib1="value">abc</element1>  <---I am trying to achive this
  <element1 attrib1="value">xyz</element1> 
</elements>

try.pl which tries to generate sample.xml file:

my $element1 = $doc->createElement('element1');
$element1->setAttribute('attrib1', $family);
insertnode($element1, 'element1', $platformName, 6);

Am I doing something wrong here? How do I add an attribute to an element?

error:

sample.xsd:3: element SimpleContent: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}complexType': The content is not valid. Expected is (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)))). WXS schema sample.xsd failed to compile


The error says that it's expecting simpleContent in the xsd, yet you supplied SimpleContent (note the upper/lower case s).

0

精彩评论

暂无评论...
验证码 换一张
取 消