xml-validation

Validate xml via dtd, different directory for dtd

筅森魡賤 提交于 2019-12-04 09:03:11
I am trying to validate an xml file via a .dtd. I have write this validator: public bool Validation(XmlDocument xmlDoc) { var xml = XmldocToString(xmlDoc); var r = new XmlTextReader(new StringReader(xml)); var settings = new XmlReaderSettings(); var sb = new StringBuilder(); settings.ProhibitDtd = false; settings.ValidationType = ValidationType.DTD; settings.ValidationEventHandler += (a, e) => { sb.AppendLine(e.Message); _isValid = false; }; XmlReader validator = XmlReader.Create(r, settings); while (validator.Read()) { } validator.Close(); return _isValid; } The problem is that I must have

Validating XML against a schema (xsd) in NodeJS

只谈情不闲聊 提交于 2019-12-04 08:07:09
问题 Do any of the XML libraries in NPM support the validation of XML against an XSD schema? I would look myself, but: $ npm search xml 2>/dev/null | wc -l 212 Note: the xsd package is not what it seems and node-xerces is broken/empty. 回答1: Hij1nx (Paolo Fragomeni) pointed me at https://github.com/polotek/libxmljs After half an hour of trying to figure out the API, I have a solution: #!/usr/local/bin/node var x = require('libxmljs'); var xsd = '<?xml version="1.0" encoding="utf-8" ?><xs:schema

XSD: default integer value range

人盡茶涼 提交于 2019-12-04 03:01:13
Is there an implied default value range when defining an element of a specific data type in an XSD file? For example if I define an element of type integer: <xs:element name="MyIntegerElement" type="xs:integer"/> Does this have an implied min and max value that it will validate to? I know I can explicitly define the valid ranges like so: <xs:element name="MyIntegerElement"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="1"/> <xs:maxInclusive value="16"/> </xs:restriction> </xs:simpleType> </xs:element> But if I don't do this when I validate an XML file against this

The element “x” in namespace “xSchema” has invalid child element “y” in namespace “xSchema”. List of possible elements expected: “y”

跟風遠走 提交于 2019-12-04 01:59:55
I am writing a schema for my XML validation final, and finally got everything (just about) working. But now I'm getting the strangest error in my XML. I'll start by showing my schema since that's where the problem should be located yet it gives me no errors. <?xml version="1.0"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:os="OrdersSchema" targetNamespace="OrdersSchema" elementFormDefault="unqualified" attributeFormDefault="qualified"> <element name="orders" type="os:orders"/> <complexType name="orders"> <sequence> <element name="order" type="os:order" maxOccurs="unbounded"/> <

Newbie: XSLT Transformation to validate rules in XML document

*爱你&永不变心* 提交于 2019-12-03 20:20:05
I'm a newbie to XSLT. I've an XML document and I need to come up with xslt to validate certain rules in the XML document. The XML and xsl file will be used in xsltproc tool and the output will be a simple Pass or Fail. Sample XML: ... <Manager mincount="4" grade="10"...> <Employee id="1" grade="9" .... /> <Employee id="2" grade="8" .... /> ..... </Manager> The number of children under Manager (Employee in this case) must be equal to or greater than the value of mincount attribute. All the employee's grade must be less than the Manager grade. Appreciate your help! TIA! Here's an XSLT 1.0 option

Validate JSON against XML Schema (XSD)

会有一股神秘感。 提交于 2019-12-03 12:27:14
Is it possible to validate JSON with an XSD in Java? I have an application where I receive JSON response, and I would like to validate it against existing XSD. Another part of my application uses XML, which is why it would be easiest if they both could validate against the existing XSD. No , XML Schema (XSD) is for validating XML ; to validate JSON , see JSON Schema . I recommend generating schemas by hand for full understanding and full control over the constraints. However, here are some automated tools that can jumpstart the process: To convert from JSON Schema to XSD, see jsons2xsd . To

XML validation with XSD: how to avoid caring about the sequence of the elements?

走远了吗. 提交于 2019-12-03 04:06:56
问题 I have following XSD code: <xsd:complexType name="questions"> <xsd:sequence> <xsd:element name="location" type="location"/> <xsd:element name="multipleChoiceInput" type="multipleChoiceInput" minOccurs="0" maxOccurs="unbounded"/> <xsd:element name="textInput" type="textInput" minOccurs="0" maxOccurs="unbounded"/> <xsd:element name="pictureInput" type="pictureInput" minOccurs="0"/> </xsd:sequence> </xsd:complexType> The problem here is: the elements location, multipleChoiceInput, etc. must

XML Validation error : EntityRef: expecting';'

ⅰ亾dé卋堺 提交于 2019-12-03 03:36:25
问题 <url> <loc>http://www.ezed.in/ezed/courseDemoIntroPage.do?courseId=COU10000000138003530&checkingCourseFrom=preLogin#.U2DcKvmSySo</loc> </url> error on line 102 at column 103: EntityRef: expecting';' Not able to figure out what could be the problem. 回答1: Your URL must be escaped. & character is used in XML to insert a character reference with syntax &name; (note ; after name). Parser expects a ; but it can't find it (there are more available delimiters, this is just most common case). Solution

Validating XML against a schema (xsd) in NodeJS

天大地大妈咪最大 提交于 2019-12-02 20:55:47
Do any of the XML libraries in NPM support the validation of XML against an XSD schema? I would look myself, but: $ npm search xml 2>/dev/null | wc -l 212 Note: the xsd package is not what it seems and node-xerces is broken/empty. Hij1nx (Paolo Fragomeni) pointed me at https://github.com/polotek/libxmljs After half an hour of trying to figure out the API, I have a solution: #!/usr/local/bin/node var x = require('libxmljs'); var xsd = '<?xml version="1.0" encoding="utf-8" ?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://example.com/XMLSchema/1.0" targetNamespace="http:/

XML validation with XSD: how to avoid caring about the sequence of the elements?

折月煮酒 提交于 2019-12-02 17:54:35
I have following XSD code: <xsd:complexType name="questions"> <xsd:sequence> <xsd:element name="location" type="location"/> <xsd:element name="multipleChoiceInput" type="multipleChoiceInput" minOccurs="0" maxOccurs="unbounded"/> <xsd:element name="textInput" type="textInput" minOccurs="0" maxOccurs="unbounded"/> <xsd:element name="pictureInput" type="pictureInput" minOccurs="0"/> </xsd:sequence> </xsd:complexType> The problem here is: the elements location, multipleChoiceInput, etc. must appear in the same order they are declared. I don't want this to happen, I want that, in the validation