Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / May 2008

Tip: Looking for answers? Try searching our database.

XSD schema problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mahmoud - 06 May 2008 14:52 GMT
Hi all,
I have a problem with xml that output from application I need to
validate one of the values by using XSD schema
The xml output like this

<?xml version="1.0" encoding="UTF-8"?>
<csv:csv xmlns:csv="http://xmlns.myapplication.com/2007/message-format/
csv"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xmlns.myapplication.com/2007/
message-format/csv right.xsd" >
  <csv:line>
     <csv:field>I</csv:field>
     <csv:field>3871</csv:field>
     <csv:field>0</csv:field> "i want to check this value"
     <csv:field>25042008</csv:field>
     <csv:field>0</csv:field>
     <csv:field>4233</csv:field>
  </csv:line>
  <csv:line>
     <csv:field>I</csv:field>
     <csv:field>3871</csv:field>
     <csv:field>29042008</csv:field>
     <csv:field>25042008</csv:field>
     <csv:field>6600183376</csv:field>
     <csv:field>4233</csv:field>
     <csv:field/>
  </csv:line>
  <csv:line>
     <csv:field>I</csv:field>
     <csv:field>3871</csv:field>
     <csv:field>29042008</csv:field>
     <csv:field>25042008</csv:field>
  </csv:line>
</csv:csv>

I get the XSD schema like this

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:csv="http://xmlns.myapplication.com/2007/message-
format/csv" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          attributeFormDefault="unqualified"
elementFormDefault="qualified" targetNamespace="http://
xmlns.myapplication.com/2007/message-format/csv"
          xmlns:xs="http://www.w3.org/2001/XMLSchema">

 <xs:element name="csv">
   <xs:complexType>
     <xs:sequence>
       <xs:element maxOccurs="unbounded" name="line">
         <xs:complexType>
           <xs:sequence>
             <xs:element maxOccurs="unbounded" name="field"
type="xs:string" minOccurs="0"/>
           </xs:sequence>
         </xs:complexType>
       </xs:element>
     </xs:sequence>
   </xs:complexType>
 </xs:element>
</xs:schema>

But the problem that I want to check the value of the third tag
<csv:field> to know if it contain 0 or 1
Can anyone help me on this
Martin Honnen - 06 May 2008 15:37 GMT
> But the problem that I want to check the value of the third tag
> <csv:field> to know if it contain 0 or 1
> Can anyone help me on this

You would need to change your schema substantially to use e.g.
  <xs:element name="field3">
    <xs:simpleType>
      <xs:restriction base="xs:int">
        <xs:maxInclusive value="1"/>
        <xs:minInclusive value="0"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
That is only possible if you choose different element names and types
for the fields, that is not possible with one field element of type
xs:string.

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

Mahmoud - 06 May 2008 16:03 GMT
> > But the problem that I want to check the value of the third tag
> > <csv:field> to know if it contain 0 or 1
[quoted text clipped - 17 lines]
>         Martin Honnen --- MVP XML
>        http://JavaScript.FAQTs.com/

Thanks Martin for your reply
But the problem that the xml doesn’t contain fields names as you see
so I do not have element name “field3" so if you have any idea to get
the third element it will be helpful
Martin Honnen - 06 May 2008 16:49 GMT
> But the problem that the xml doesn’t contain fields names as you see
> so I do not have element name “field3" so if you have any idea to get
> the third element it will be helpful

If you want to use the XSD schema language then you will need to change
the schema you have and the XML you have.
As an alternative you could use a language like Schematron to formulate
the condition you have: http://www.schematron.com/

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.