Jump to content

XML Schema for reading matrices

Recommended Posts

Hi, I am very new to using XML and making my first XML Schema. I want to write something in XML schema that will allow me to read a matrix. For example, I want to have a matrix that looks like this:

<matrix >  <row >2.1 3.4</row>  <row >100.5 6.7</row>  <row >-2.76 5.9</row>  <row >-7.53 -30.21</row></matrix>

All the values in this matrix will be decimals (no limits) and there will only be 2 values in each row. In addition, there is no restriction on the number of rows so when I am reading the XML, I want to continue reading until the last row is read. How will I write an XML schema that will allow me to verify this? So far I have got something like:

<xs:element name="row" type="valuelist"><xs:simpleType name="valuelist">  <xs:list itemType="xs:decimal"/></xs:simpleType>

I think this will allow me to read a row, but it doesn't let me place a limit of only 2 values in a row. And how would I read all the rows in a matrix? Thanks for your help!Alisha

Edited by ay.a1234
Link to post
Share on other sites

I'm not certain, but maybe the <length> restriction would work: http://www.w3schools.com/schema/schema_facets.asp If you had a set of <col> elements inside the <row> element, you could use the minOccurs and maxOccurs attributes to restrict the amount of columns you're allowed to add to the matrix. Schema doesn't "read" XML files, it's just there for validation so a user can know if they wrote the document properly.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...