Search Results

Search found 19474 results on 779 pages for 'xml validation'.

Page 10/779 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Checking validation of entries in a Sudoku game written in Java

    - by Mico0
    I'm building a simple Sudoku game in Java which is based on a matrix (an array[9][9]) and I need to validate my board state according to these rules: all rows have 1-9 digits all columns have 1-9 digits. each 3x3 grid has 1-9 digits. This function should be efficient as possible for example if first case is not valid I believe there's no need to check other cases and so on (correct me if I'm wrong). When I tried doing this I had a conflict. Should I do one large for loop and inside check columns and row (in two other loops) or should I do each test separately and verify every case by it's own? (Please don't suggest too advanced solutions with other class/object helpers.) This is what I thought about: Main validating function (which I want pretty clean): public boolean testBoard() { boolean isBoardValid = false; if (validRows()) { if (validColumns()) { if (validCube()) { isBoardValid = true; } } } return isBoardValid; } Different methods to do the specific test such as: private boolean validRows() { int rowsDigitsCount = 0; for (int num = 1; num <= 9; num++) { boolean foundDigit = false; for (int row = 0; (row < board.length) && (!foundDigit); row++) { for (int col = 0; col < board[row].length; col++) { if (board[row][col] == num) { rowsDigitsCount++; foundDigit = true; break; } } } } return rowsDigitsCount == 9 ? true : false; } I don't know if I should keep doing tests separately because it looks like I'm duplicating my code.

    Read the article

  • Is server validation necessary with client-side validators?

    - by peroija
    I recently created a .net web app that used over 200 custom validators on one page. I wrote code for both ClientValidationFunction and OnServerValidate which results in a ton of repetitive code. My sql statements are parameterized, I have functions that pull data from input fields and validates them before passing to the sql statements or stored procedures. And the javascript validates the fields before the page submits. So essentially the data is clean and valid before it even hits the OnServerValidate and clean after it anyways due to the aforementioned steps. This makes me question, is OnServerValidate really needed when I validate on the clientside?

    Read the article

  • JQuery Validation [migrated]

    - by user41354
    Im trying to get my form to validate...so basically its working, but a little bit too well, I have two text boxes, one is a start date, the other an end date in the format of mm/dd/yyyy if the start date is greater than the end date...there is an error if the end date is less than the start date...there is an error if the start date is less than today's date...there is an error The only thing is when I correct the error, the error warning is still there...here is my code: dates.change(function () { var testDate = $(this).val(); var otherDate = dates.not(this).val(); var now = new Date(); now.setHours(0, 0, 0, 0); // Pass Dates if (testDate != '' && new Date(testDate) < now) { addError($(this)); $('.flightDateError').text('* Dates cannot be earlier than today.'); isValid = false; return; } // Required Text if ($(this).hasClass("FromCal") && testDate == '') { addError($(this)); $('.flightDateError').text('* Required'); isValid = false; return; } // Validate Date if (!isValidDate(testDate)) { // $(this).addClass('validation_error_input'); addError($(this)); $('.flightDateError').text('* Invalid Date'); isValid = false; return; } else { // $(this).removeClass('validation_error_input'); removeError($(this)); if (!dates.not(this).hasClass('validation_error_input')) $('.flightDateError').text(' '); } // Validate Date Ranges if ($(this).val() != '' && dates.not(this).val != '') { if ($(this).hasClass("FromCal")) { if (new Date(testDate) > new Date(otherDate)) { addError($(this)); $('.flightDateError').text('* Start date must be earlier than end date.'); isValid = false; return; } } else{ if (new Date(testDate) < new Date(otherDate)) { addError($(this)); $('.flightDateError').text('* End date must be later than start date.'); return; } } } }); The main Issue is this part, I believe // Validate Date Ranges if ($(this).val() != '' && dates.not(this).val != '') { if ($(this).hasClass("FromCal")) { if (new Date(testDate) > new Date(otherDate)) { addError($(this)); $('.flightDateError').text('* Start date must be earlier than end date.'); isValid = false; return; } } else{ if (new Date(testDate) < new Date(otherDate)) { addError($(this)); $('.flightDateError').text('* End date must be later than start date.'); return; } } } testDate is the start date otherDate is the end date Thanks in advanced, J

    Read the article

  • Build XML document using Linq To XML

    - by JasonDR
    Given the following code: string xml = ""; //alternativley: string xml = "<people />"; XDocument xDoc = null; if (!string.IsNullOrEmpty(xml)) { xDoc = XDocument.Parse(xml); xDoc.Element("people").Add( new XElement("person", "p 1") ); } else { xDoc = new XDocument(); xDoc.Add(new XElement("people", new XElement("person", "p 1") )); } As you can see, if the xml variable is blank, I need to create the rood node manually, and append the person the root node, whereas if it is not, I simple add to the people element My question is, is there any way to generically create the document, where it will add all referenced node automatically if they do not already exists?

    Read the article

  • Validating XML tag by tag

    - by Greatful
    Hi All I'm having some issues validating some XML against a Schema, using .net and C#. I am using XmlReaderSettings with the ValidationEventHandler. However, this seems to stop catching errors after it has encountered the first error at a particular level within the XML file, instead of checking the next tag at the same level, so basically it does not check each and every tag within the XML file instead skipping a level when it has found an error. I was hoping to get some advice from somebody who has successfully accomplished this type of validation. Thanks very much

    Read the article

  • how to write xsd for the following xml?

    - by Venkats
    <?xml version="1.0"?> <datatype xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="sampletype.xsd"> <table name="emp"> <columns> <column> <name>emp_id</name> <data_type>int(200) </data_type> </column> </columns> </table> </datatype> Here i generate the xsd for above xml, but it was not correct. can you help me generate the xsd for the xml? thanks in advance.

    Read the article

  • android sdk main.out.xml parsing error?

    - by mobibob
    I just started a new Android project, "WeekendStudy" to continue learning Android development and I got stumped compiling the default 'hello weekendstudy' compile / run. I think that I missed a step in configuration and setup, but I am at a loss to find out where. I have an AVD configured, set and launched. When I press 'run', the SDK is building a file main.out.xml and then fails as this: [2010-03-06 09:46:47 - WeekendStudy]Error in an XML file: aborting build. [2010-03-06 09:46:48 - WeekendStudy]res/layout/main.xml:0: error: Resource entry main is already defined. [2010-03-06 09:46:48 - WeekendStudy]res/layout/main.out.xml:0: Originally defined here. [2010-03-06 09:46:48 - WeekendStudy]/Users/mobibob/Projects/workspace-weekend/WeekendStudy/res/layout/main.out.xml:1: error: Error parsing XML: no element found [2010-03-06 09:48:16 - WeekendStudy]Error in an XML file: aborting build. [2010-03-06 09:48:16 - WeekendStudy]res/layout/main.xml:0: error: Resource entry main is already defined. [2010-03-06 09:48:16 - WeekendStudy]res/layout/main.out.xml:0: Originally defined here. [2010-03-06 09:48:16 - WeekendStudy]/Users/mobibob/Projects/workspace-weekend/WeekendStudy/res/layout/main.out.xml:1: error: Error parsing XML: no element found [2010-03-06 09:55:29 - WeekendStudy]res/layout/main.xml:0: error: Resource entry main is already defined. [2010-03-06 09:55:29 - WeekendStudy]res/layout/main.out.xml:0: Originally defined here. [2010-03-06 09:55:29 - WeekendStudy]/Users/mobibob/Projects/workspace-weekend/WeekendStudy/res/layout/main.out.xml:1: error: Error parsing XML: no element found [2010-03-06 09:55:49 - WeekendStudy]Error in an XML file: aborting build. [2010-03-06 09:55:49 - WeekendStudy]res/layout/main.xml:0: error: Resource entry main is already defined. [2010-03-06 09:55:49 - WeekendStudy]res/layout/main.out.xml:0: Originally defined here. [2010-03-06 09:55:49 - WeekendStudy]/Users/mobibob/Projects/workspace-weekend/WeekendStudy/res/layout/main.out.xml:1: error: Error parsing XML: no element found

    Read the article

  • Element was not expected While Deserializing an Array with XML Serialization

    - by Anthony Shaw
    OK. I'm trying to work on communicating with the Pivotal Tracker API, which only returns data in an XML format. I have the following XML that I'm trying to deserialize into my domain model. <?xml version="1.0" encoding="UTF-8"? <stories type="array" count="2" total="2" <story <id type="integer"2909137</id <project_id type="integer"68153</project_id <story_typebug</story_type <urlhttp://www.pivotaltracker.com/story/show/2909137</url <current_stateunscheduled</current_state <description</description <nameTest #2</name <requested_byAnthony Shaw</requested_by <created_at type="datetime"2010/03/23 20:05:58 EDT</created_at <updated_at type="datetime"2010/03/23 20:05:58 EDT</updated_at </story <story <id type="integer"2909135</id <project_id type="integer"68153</project_id <story_typefeature</story_type <urlhttp://www.pivotaltracker.com/story/show/2909135</url <estimate type="integer"-1</estimate <current_stateunscheduled</current_state <description</description <nameTest #1</name <requested_byAnthony Shaw</requested_by <created_at type="datetime"2010/03/23 20:05:53 EDT</created_at <updated_at type="datetime"2010/03/23 20:05:53 EDT</updated_at </story </stories My 'story' object is created as follows: public class story { public int id { get; set; } public int estimate { get; set; } public int project_id { get; set; } public string story_type { get; set; } public string url { get; set; } public string current_state { get; set; } public string description { get; set; } public string name { get; set; } public string requested_by { get; set; } public string labels { get; set; } public string lighthouse_id { get; set; } public string lighthouse_url { get; set; } public string owned_by { get; set; } public string accepted_at { get; set; } public string created_at { get; set; } public attachment[] attachments { get; set; } public note[] notes { get; set; } } When I execute my deserialization code, I receive the following exception: Exception: There is an error in XML document (2, 2). Inner Exception: <stories xmlns='' was not expected. I can deserialize the individual stories just fine, I just cannot deserialize this xml into an array of 'story' objects And my deserialization code (value is a string of the xml) var byteArray = Encoding.ASCII.GetBytes(value); var stream = new MemoryStream(byteArray); var deserializedObject = new XmlSerializer(typeof (story[])).Deserialize(stream) Does anybody have any ideas?

    Read the article

  • Convert xml as string

    - by hakish
    i have a scenario where in i need to send an xml as a tag content in a SOAP request message to a webservice for example <arg_1><xml version="1.0" encoding="UTF-8"?><sometag><somemoretag>abcd</somemoretag></sometag></arg_1></code> arg_1 happens to be an String parameter to a webservice. So i bring in a CDATA section for this <arg_1><![CDATA[<xml version="1.0" encoding="UTF-8"?><sometag><somemoretag>abcd</somemoretag></sometag>]]></arg_1> But this keeps throwing me an exception org.xml.sax.SAXException: WSWS3084E: Error: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize. Message being parsed: I keep getting this exception. Has anyone seen this before??

    Read the article

  • Parsing XML in a non-XML column

    - by slugster
    Hi, i am reasonably proficient with SQLServer, but i'm not a DBA so i'm not sure how to approach this. I have an XML chunk stored in an ntext column. Due to it being a legacy database and the requirements of the project i cannot change the table (yet). This is an example of the data i need to manipulate: <XmlSerializableHashtable xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Entries> <Entry> <key xsi:type="xsd:string">CurrentYear</key><value xsi:type="xsd:string">2010</value> </Entry> <Entry> <key xsi:type="xsd:string">CurrentMonth</key><value xsi:type="xsd:string">4</value> </Entry> </Entries> </XmlSerializableHashtable> each row will have a chunk like this, but obviously with different keys/values in the XML. Is there any clever way i can parse this XML in to a name/value pairs style view? Or should i be using SQLServer's XML querying abilities even though it isn't an XML column? If so, how would i query a specific value out of that column? (Note: adding a computed XML column on the end of the table is a possibility, if that helps). Thanks for any assistance!

    Read the article

  • XML Deserialization in VB/VBA

    - by oharab
    I have a set of VBA classes in an MS Access database. I have an xml string with data I want to create new classes with. Other than setting each property individually, is there an easy way to deserialize the XML into my object? I've seen the code using the TypeLib library Public Sub ISerializable_Deserialize(xml As IXMLDOMNode) Dim tTLI As TLIApplication Dim tInvoke As InvokeKinds Dim tName As String Dim tMem As MemberInfo tInvoke = VbLet For Each tMem In TLI.ClassInfoFromObject(Me).Members tName = LCase(tMem.Name) CallByName Me, tMem.Name, VbLet, xml.Attributes.getNamedItem(tName).Text Next tMem End Sub but this doesn't seem to work with the standard class modules. I get a 429 error: ActiveX Component Cannot Be Created Can anyone else help me out? I'd rather not have to set each propery by hand if I can help it, some of these classes are huge!

    Read the article

  • Parsing third-party XML

    - by mare
    What path would you took to parse a large XML file (2MB - 20 MB or more), that does not have a schema (I cannot infer one with XSD.exe because the file structure is odd, check the snippet below)? Options 1) XML Deserialization (but as said, I don't have a schema and XSD tool complains about the file contents), 2) Linq to XML, 3) loading into XmlDocument, 4) Manual parsing with XmlReader & stuff. This is XML file snippet: <?xml version="1.0" encoding="utf-8"?> <xmlData date="29.04.2010 12:09:13"> <Table> <ident>079186</ident> <stock>0</stock> <pricewotax>33.94000000</pricewotax> <discountpercent>0.00000000</discountpercent> </Table> <Table> <ident>079190</ident> <stock>1</stock> <pricewotax>10.50000000</pricewotax> <discountpercent>0.00000000</discountpercent> <pricebyquantity> <Table> <quantity>5</quantity> <pricewotax>10.00000000</pricewotax> <discountpercent>0.00000000</discountpercent> </Table> <Table> <quantity>8</quantity> <pricewotax>9.00000000</pricewotax> <discountpercent>0.00000000</discountpercent> </Table> </pricebyquantity> </Table> </xmlData>

    Read the article

  • Binding XML in Sliverlight without Nominal Classes

    - by AnthonyWJones
    Lets say I have a simple chunck of XML:- <root> <item forename="Fred" surname="Flintstone" /> <item forename="Barney" surname="Rubble" /> </root> Having fetched this XML in Silverlight I would like to bind it with xaml of this ilke:- <ListBox x:Name="ItemList" Style="{StaticResource Items}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBox Text="{Binding Forename}" /> <TextBox Text="{Binding Surname}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> Now I can bind simply enough with LINQ to XML and a nominal class:- public class Person { public string Forename {get; set;} public string Surname {get; set;} } So here is the question, can it be done without this class? IOW coupling between the Sliverlight code and the input XML is limited to the XAML only, other source code is agnostic to the set of attributes on the item element. Edit: The use of XSD is suggested but ultimately it amounts the same thing. XSD-Generated class. Edit: An anonymous class doesn't work, Silverlight can't bind them. Edit: This needs to be two way, the user needs to be able to edit the values and these value end up in the XML. (Changed original TextBlock to TextBox in sample above).

    Read the article

  • Mutating XML in Clojure

    - by mac
    Clojures clojure.xml/parse, clojure.zip/xml-zip and clojure.contrib.zip-filter.xml/xml- are excellent tools for pulling values out of xml, but what if I want to change the xml (the result of clojure.zip/xml-zip) based on what I learn from xml- "queries" and write the result back out as xml? I would have expected that (clojure.contrib.prxml/prxml (clojure.xml/parse xml-content)) spit back xml, but that is not the case.

    Read the article

  • RESTful Web Services: Different XML Representation for the same resource

    - by AlexImmelman
    Hi, I'm developing a REST Web Service using a XML format response and I have some problems (Really, one problem). One of my resources has some final fields so once they're created, they can't be modified. According to that, I need different representations for this resource depending on what I'm doing: Creating or modifiying it. What should I do, give to the user different XML-Schemas for the same resource or write just one XML-Schema and read some fields or not depending on the method I'm being requested?? Thanks

    Read the article

  • LINQ to XML via C#

    - by user70192
    Hello, I'm new to LINQ. I understand it's purpose. But I can't quite figure it out. I have an XML set that looks like the following: <Results> <Result> <ID>1</ID> <Name>John Smith</Name> <EmailAddress>[email protected]</EmailAddress> </Result> <Result> <ID>2</ID> <Name>Bill Young</Name> <EmailAddress>[email protected]</EmailAddress> </Result> </Results> I have loaded this XML into an XDocument as such: string xmlText = GetXML(); XDocument xml = XDocument.Parse(xmlText); Now, I'm trying to get the results into POCO format. In an effort to do this, I'm currently using: var objects = from results in xml.Descendants("Results") select new Results // I'm stuck How do I get a collection of Result elements via LINQ? I'm particularly confused about navigating the XML structure at this point in my code. Thank you!

    Read the article

  • Parsing JSON into XML using Windows Phone

    - by Henry Edwards
    I have this code, but can't get it all working. I am trying to get a json string into xml. So that I can get a list of items when i parse the data. Is there a better way to parse json into xml. If so what's the best way to do it, and if possible could you give me a working example? The URL that is in the code is not the URL that i am using using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using Microsoft.Phone.Controls; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Schema; using Newtonsoft.Json.Bson; using System.Xml; using System.Xml.Serialization; using System.Xml.Linq; using System.Xml.Linq.XDocument; using System.IO; namespace WindowsPhonePanoramaApplication3 { public partial class Page2 : PhoneApplicationPage { public Page2() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e1) { /* because the origional JSON string has multiple root's this needs to be added */ string json = "{BFBC2_GlobalStats:"; json += DownlodUrl("http://api.bfbcs.com/api/xbox360?globalstats"); json += "}"; XmlDocument doc = (XmlDocument)JsonConvert.DeserializeObject(json); textBox1.Text = GetXmlString(doc); } private string GetXmlString() { throw new NotImplementedException(); } private string DownlodUrl(string url) { string result = null; try { WebClient client = new WebClient(); result = client.DownloadString(url); } catch (Exception ex) { // handle error result = ex.Message; } return result; } private string GetXmlString(XmlDocument xmlDoc) { sw = new StringWriter(); XmlTextWriter xw = new XmlTextWriter(sw); xw.Formatting = System.Xml.Formatting.Indented; xmlDoc.WriteTo(xw); return sw.ToString(); } } } The URL outputs the following code: {"StopName":"Race Hill", "stopId":7553, "NaptanCode":"bridwja", "LongName":"Race Hill", "OperatorsCode1":" 5", "OperatorsCode2":" ", "OperatorsCode3":" ", "OperatorsCode4":"bridwja", "Departures":[ { "ServiceName":"", "Destination":"", "DepartureTimeAsString":"", "DepartureTime":"30/01/2012 00:00:00", "Notes":""}` Thanks for your responses. So Should i just leave the data a json and then view the data via that??? Is this a way to show the data from a json string. public void Load() { // form the URI UriBuilder uri = new UriBuilder("http://mysite.com/events.json"); WebClient proxy = new WebClient(); proxy.OpenReadCompleted += new OpenReadCompletedEventHandler(OnReadCompleted); proxy.OpenReadAsync(uri.Uri); } void OnReadCompleted(object sender, OpenReadCompletedEventArgs e) { if (e.Error == null) { var serializer = new DataContractJsonSerializer(typeof(EventList)); var events = (EventList)serializer.ReadObject(e.Result); foreach (var ev in events) { Items.Add(ev); } } } public ObservableCollection<EventDetails> Items { get; private set; } Edit: Have now kept the url as json and have now got it working by using the json way.

    Read the article

  • C# encrypt whole XML File

    - by René
    I already have a solution for encrypting of several XML nodes or strings. But of course, you can open the local saved XML file and you should see the node tags. For some intelligent people it could be a reference for hidden informations. Is there any way to encrypt and decrypt the whole xml content including all node tags?

    Read the article

  • Formatting datetime values returned in a SELECT..FOR XML statement

    - by TelJanini
    Consider the following table: Orders OrderId Date CustomerId 1000 2012-06-05 20:03:12.000 51 1001 2012-06-16 12:02:31.170 48 1002 2012-06-18 19:45:16.000 33 When I extract the Order data using FOR XML: SELECT OrderId AS 'Order/@Order-Id', Date AS 'Order/ShipDate', CustomerId AS 'Order/Customer' FROM Orders WHERE OrderId = 1000 FOR XML PATH ('') I get the following result: <Order Order-Id="1000"> <ShipDate>2010-02-20T16:03:12</ShipDate> <Customer>51</Customer> </Order> The problem is, the ShipDate value in the XML file needs to be in the format M/DD/YYYY H:mm:ss PM. How can I change the output of the ShipDate in the XML file to the desired format? Any help would be greatly appreciated!

    Read the article

  • Code to read & write in XML

    - by user2954088
    I am trying to write code to read and write the XML but I am facing some errors, Could please someone provide the sample code to read XML in grid and can update/insert data from grid which will be saved in following sample xml file. Sample XML file: I am facing the below exception: The assembly with display name '...XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly '.....XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

    Read the article

  • Javascript form validation on client side without server side - is it safe?

    - by Vitali Ponomar
    Supose I have some form with javascript client side validation and no server side validation. If user disable javascript in his browser there will no be submit button so he can not send me any data without js enabled. But I do not know is there any way to change my validation instructions from client browser so he could send me untrusted data and make some damage to my database. Thanks in advance and sorry for my (possibly) obvious question!!!

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >