Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 6th, 2011, 05:03 PM
Authorized User
 
Join Date: Nov 2011
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default error in xml validation with xsd schema.

Hi every one,
I am new to xml data files,I have two xml files with same data but only small difference as shown below
Code:
<List>
    <number>1101</number>
  <Area>inner walls in a room.</Area>
  <Detection>less pressure.</Detection>
  <reason>
    <normal>
      <Component Num="15" Type="electric">
        <Beha Num="97" working="yes" acceptrate="100"/>
      </Component>
    </normal>
  </reason>
  <reaction>
    <Informal/>
  </reaction>
  <action>
    <Informal>some data here.
</Informal>
  </action>
</list>
second xml file
Code:
<List>
    <number>1102</number>
  <Area>outer  of  room.</Area>
  <Detection>more pressure.</Detection>
  <reason/>
  <reaction>
    <Informal/>
  </reaction>
  <action/>
</list>
In the above two xml files the difference is in second xml file i Have two empty tag elements One is action and another is reason tags. I created one xsd file file using xmlpad for frist xml file and validated using that xsd , Its giving no errors, but when I tried same xsd for second xml file it giving error like.
Code:
element action{}has invalid structure for schema definition:(informal)
used xsd is like this
Code:
  <xs:element name="Action">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Informal" minOccures="0"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
<xs:element name="Informal" type="xs:string"/>
same error for reason tags also, I tried in different ways but problem not solved can any one suggest me how to solve this problem.
Thanks in advance.
 
Old December 6th, 2011, 05:18 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your general approach is correct - define minOccurs="0" to make the contained element optional. But the code you have shown us contains basic spelling mistakes, so it can't be your real code. Show us your real code, and the actual error messages, and we should be able to help you.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old December 6th, 2011, 05:42 PM
Authorized User
 
Join Date: Nov 2011
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi mhkay,
provided code is not original but the format is same, due to security problems i cant post my original code but it look likes as above code, my problem is in one xml file i have some content in the action tag but in another xml i have empty tag, so how can i solve this problem because already i tried with minOccurs but still problem is there. any more suggestions.
thanks in advance.
 
Old December 6th, 2011, 06:02 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If you can't show me your code then I cana't debug it for you.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
XML Schema Validation - meaningful error msg stolte XML 0 June 8th, 2010 11:37 AM
create xml with xsd validation obaxe3k XSLT 1 August 13th, 2008 09:43 AM
XML validation with XSD ksskumar XML 0 October 12th, 2007 04:46 AM
XML schema validation problems BrendonMelville XML 3 February 15th, 2006 06:02 PM
xml validation with xsd amolkad XML 0 June 24th, 2004 06:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.