xml-validation

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);

Validate XML with loading schemas at runtime, failure depending on schema order

霸气de小男生 提交于 2020-01-02 03:42:05
问题 I am trying to do xml validation. I am being given a list of schemas at run-time (possibly wrapped in a jar). Validation passes or failes based on the order in which I provide the schemas to the SchemaFactory. Here is what I am doing: private void validateXml(String xml, List<URI> schemas){ Source[] source = new StreamSource[schemas.size()]; int i=0; for (URI f : schemas){ source[i++] = new StreamSource(f.openStream()); } SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML

Difference between <xsd:all> and <xsd:sequence> in schema definition?

怎甘沉沦 提交于 2019-12-29 13:37:18
问题 I am using xsd:all in a complex type. When I miss any mandatory elements while validating it will show all the elements. It will not display the exact missed element. But if I am use xsd:sequence I can get the exact missed element. Is there any difference between these two? xsd:sequence : XML element must be in same order. But xsd:all : XML element may be any order. 回答1: <xsd:all> specifies that the child elements can appear in any order. <xsd:sequence> specifies child elements can only

Difference between <xsd:all> and <xsd:sequence> in schema definition?

坚强是说给别人听的谎言 提交于 2019-12-29 13:37:05
问题 I am using xsd:all in a complex type. When I miss any mandatory elements while validating it will show all the elements. It will not display the exact missed element. But if I am use xsd:sequence I can get the exact missed element. Is there any difference between these two? xsd:sequence : XML element must be in same order. But xsd:all : XML element may be any order. 回答1: <xsd:all> specifies that the child elements can appear in any order. <xsd:sequence> specifies child elements can only

Does qunit-reporter-junit generate junit compatible xml?

你。 提交于 2019-12-29 08:06:13
问题 I just used qunit-reporter-junit to generate the following XML: <?xml version="1.0" encoding="UTF-8"?> <testsuites name="http://w188823.example.com:9001/test/workflow.cloning?out=xml" hostname="localhost" tests="19" failures="2" errors="0" time="0.357" timestamp="2013-07-16T19:52:00Z"> <testsuite id="0" name="workflow.cloning.test" hostname="localhost" tests="4" failures="0" errors="0" time="0.002" timestamp="2013-07-16T19:52:00Z"> <testcase name="has schedule departure date predicate" tests=

how to display actionerror messages beside the field in struts while using xml validation

坚强是说给别人听的谎言 提交于 2019-12-25 14:22:55
问题 here's what i did i have created a jsp page cardholder <%@ page contentType="text/html; charset=UTF-8"%> <%@ taglib prefix="s" uri="/struts-tags"%> <!DOCTYPE HTML> <% String client = (String) request.getAttribute("clientId"); %> <html> <head> <style type="text/css"> h3 { font-family: Calibri; font-size: 22pt; font-style: normal; font-weight: bold; color: SlateBlue; text-align: center; text-decoration: underline } table { font-family: Calibri; color: white; font-size: 11pt; font-style: normal;

Validate descendants of unknown XML elements via XSD?

↘锁芯ラ 提交于 2019-12-24 18:02:07
问题 My XML file looks like : <root> <template> <unknownTag> <anotherUnknownTag/> <anotherKnownTag/> <field name='price'/> </unknownTag> </template> <template> <field name='salary'/> </template> <anothorKnownTag/> </root> I want to apply regex restriction to the attribute name of the tag <field/> whether it's a child or a grandchild or a grand grandchild and so on. I have tried the following code, but the regex only applied to the element field when it's a direct child of the template tag. <xs

Use datatype directly with in XML

让人想犯罪 __ 提交于 2019-12-24 15:25:47
问题 I'm trying to validate below XML with the below XSD: XML <Device xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Parameter Id="100" Flag="100" xsi:type="xsd:unsignedInt">-100</Parameter> </Device> XSD <?xml version="1.0" encoding="UTF-8" ?> <xsd:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="Device"> <xsd:complexType> <xsd:sequence> <xsd:element name='Parameter'

no declaration found for element 'n4:Envelope'

若如初见. 提交于 2019-12-24 14:10:52
问题 I am not sure how to solve this error: no declaration found for element 'n4:Envelope' . I need to get a better understanding of xml schemas and how they are declared. What declaration is it talking about? Anyone can help on this? This is the start of xml file: <?xml version="1.0"?> <n4:Envelope xmlns:http="http://schemas.xmlsoap.org/wsdl/" xmlns:n="http://www.informatica.com/wsdl/" xmlns:n4="http://schemas.xmlsoap.org/soap/envelope/" xmlns:n5="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http

In XSD I want to specify that an element can only have whitespace content

泄露秘密 提交于 2019-12-24 11:37:30
问题 The following XSD should allow for an element called OnlyWhiteSpaceElement which has a required Name attribute, and can have only whitespace content: <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="OnlyWhiteSpaceType"> <xs:simpleContent> <xs:extension base="OnlyWhiteSpaceContentType"> <xs:attribute name="Name" type="xs:string" use="required"/> </xs:extension> </xs:simpleContent> </xs:complexType> <xs:simpleType name=