xsd

Error while validating XML against XSD

守給你的承諾、 提交于 2020-01-03 13:31:09
问题 I got a simple XML file that I want to validate against an XSD. When I validate with some random validator, I always get the following error: Invalid content was found starting with element 'Entities'. One of '{Entities}' is expected. Here's the XML: <BusinessModel xmlns="http://schemas.testxyzxyz.de/xyz/BusinessModel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Entities> <Entity Name="Customer"> <Attribute Name="Forename" Type="String" /> <Attribute Name="Surname" Type="String" /

XSD schema: How to specify the number of digits in a value?

这一生的挚爱 提交于 2020-01-03 12:59:11
问题 i want to limit the number of digits allowed in an element to 6: <AccountNumber>123456</AccountNumber> <AccountNumber>999999</AccountNumber> <AccountNumber>000000</AccountNumber> The field format specification is 6-digit, zero-padded, numeric. i read that i might want to use the totalDigits restriction, based on: totalDigits Specifies the exact number of digits allowed. Must be greater than zero So i have the simple type: <xs:simpleType name="AccountNumber"> <xs:restriction base="xs:int"> <xs

Java XML validation does not work when schema comes from classpath

血红的双手。 提交于 2020-01-03 12:14:08
问题 I am validating XML documents against a schema. Some more complex documents/schemas always fail when trying to validate them using this code: DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); dbfac.setNamespaceAware(true); dbfac.setIgnoringElementContentWhitespace(true); DocumentBuilder docBuilder = dbfac.newDocumentBuilder(); Document doc = docBuilder.parse("sampleResponse.xml"); SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

How to approach writing an F# type provider that enforces complex schema?

守給你的承諾、 提交于 2020-01-03 10:17:09
问题 Just recently I worked with some data for traffic and travel information, that is data in Datex2 format. The project wasn't long and is over now, and I went on as usually and generated a bunch of strongly typed C# classes with xsd.exe tool, did some serializing, light processing and so forth. However, now in hindsight I became to wonder if this would have been a good case for an F# type provider and so to take my first stab on this subject. With this in mind, how should one approach a

Why doesn't the /reference option to svcutil.exe work?

£可爱£侵袭症+ 提交于 2020-01-03 08:43:10
问题 I'm attempting to use svcutil.exe to generate -only- the service contracts (interfaces) from a set of .wsdl files. When I do this (from an http-hosted wsdl), it picks up the included schemas and generates all the code for them. Great. What I would REALLY like to do, however, is to use a set of classes already generated from the schema files using the xsd.exe tool (the reasons for this are not important, suffice it to say that I need to have the types in one assembly, and the service contracts

What is the difference between XSD choice and enumeration?

跟風遠走 提交于 2020-01-03 08:40:16
问题 What is the difference between XSD choice and enumeration? 回答1: They are completely unrelated. Choice indicates that within the content model of an element, you can use one of several child elements: for example within a document you have a choice of chapter or appendix as child elements. Enumeration is used to restrict the values that can appear in a text or attribute node, for example to say that the value of a color attribute must be red, green, or blue. 回答2: XSD choice allows you to

regex pattern to allow positive and negative integers

假如想象 提交于 2020-01-03 08:32:45
问题 I am trying to find regex pattern in XSD that allow both positive and negative integers My current code allows only positive integers. xs:pattern value="[0-9]{0,10}" 回答1: Assuming you only mention an optional negative sign in front of the number: xs:pattern value="-?[0-9]{0,10}" 回答2: Using the \d notation would make it even simpler: xs:pattern value="-?\d+" 回答3: if you using python: example re.findall: regex=re.findall(r'(-?[\d]+)',somestring) *output: [negative integer, integer] 来源: https:/

How to define mutually exclusive attributes in XSD?

泄露秘密 提交于 2020-01-03 08:22:10
问题 First the code fragment... <tag name="default" abc="10" def="20> <!-- not valid, abc and def should be mutually exclusive --> <tag name="default1" abc="10"> <!-- valid --> <tag name="default2" def="20> <!-- valid --> What I want to do... What can I put into my XSD so that @abc and @def cannot coexist as attributes on the same element? So that validation would fail if they coexisted on the same element? 回答1: XSD 1.0 Can be done with clever trick using xs:key . See @Kachna's answer. Note that

XML format specification (DTD, XSD..) for Unit Test Reports

岁酱吖の 提交于 2020-01-03 08:13:12
问题 A lot of tools produces and consumes the same XML File format for Unit Test report. Example (source): <?xml version="1.0" encoding="UTF-8" ?> <testsuite errors="0" failures="0" hostname="hazelnut.osuosl.org" name="net.cars.engine.MoteurTest" tests="6" time="0.021" timestamp="2007-11-02T23:13:50"> <properties> <property name="java.vendor" value="IBM Corporation" /> <property name="os.name" value="Linux" /> <!-- more property tags--> </properties> <testcase classname="net.cars.engine.MoteurTest

JAXB Schema validation when unmarshalling non-root element

≯℡__Kan透↙ 提交于 2020-01-03 07:32:43
问题 When you unmarshal whole XML with JAXB, you can set XML schema to enable validation during parsing: //javax.xml.validation.Schema schema = ... jaxbUnmarshaller = JAXBContext.newInstance(SomeRootType.class).createUnmarshaller(); jaxbUnmarshaller.setSchema(schema); On the other hand, when you unmarshal list of NestedObjest s from XML, one by one (eg. to decrease memory usage) this method fails (as Schema only accepts root) with an exception: org.xml.sax.SAXParseException; lineNumber: 2;