Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

In an xml file plus schema I have an entry set as type integer.

 

However the only way I can get the sorting to work correctly when using dataview is to whack a load of leading zeros in front of the number?

 

Any ideas?

My website
  • *Experts*
Posted

Can you verify that the DataSet itself thinks the value is an int? You can check the datatype of a column once your DataSet is loaded.

 

Maybe you're not reading in the file with the schema? In the ReadXml method (if that's what you're using), there's a second param that specifies how to treat the schema (read, infer, etc.).

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

Hi, the datatype is String?

 

I know the xsd file is being read as when I make a change to the xml file not contained in the xsd if throws an error which I would expect it to do.

 

Here's the code snippet;

 

' read in xml file

objXTReader = New XmlTextReader(strXMLFilePath)

' parse xml thro validator

objXValReader = New XmlValidatingReader(objXTReader)

' add to schema collection

xscCollection.Add("http://tempuri.org/HighScores.xsd", strXSDFilePath)

' set handler of validation event handler to our sub

AddHandler objXValReader.ValidationEventHandler, AddressOf ValidationCallBack

' add scheam collection to validation reader

objXValReader.Schemas.Add(xscCollection)

' load xml file into dataset validate on the way

dsHighScores.ReadXml(objXValReader)

My website
Posted
OK I either get an exception or no change depending on which second param I use. I cannot get it to read the second column in as an integer even tho the schema states that it is?
My website
Posted

Still stuck with this? I'll go a little deeper with the setup.

 

I create an xml file and use the IDE create schema option which sets the score field to being a string rather than integer?

 

I change the type setting in the schema to be xs:integer

 

When I load the dataset thru an xmlreader thru and xmlvalidator it works ok. If I make an illegal change to the xml file and load again it errors stating it is illegal so I know that when it is being read into the dataset it is getting validated.

 

However it still thinks the score field is a string?

 

If I try your suggestion Nerseus I get errors on some or no change on others? From reading more on the readxml method I understand the second param is to be used on inline schema not an external xsd file?

 

So I'm completely stuck? I can't get the dataset to load the xml file as two columns, one string and one integer. It keeps loading them as two string fileds?

 

So I am forced to pad the score field in the xml file out with leading zeros to get the sort to work right??

 

Anyone....pls help :(

My website
Posted

OK, so here I am with a work around that has fixed the problem, but altho it works it still seems OTT for what is needed.

 

I created a dataset class using the schema and then created a global object of this. I load my xml into this object and it all works fine.

 

So problem solved, but I think this is messy tho:)

My website

Join the conversation

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

Guest
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...