FAQ Database Discussion Community


XML validation: why is explicitly specifying a namespace not allowed in this case?

xml,validation,xsd,xml-namespaces
Given the following XSD: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:foo="urn:foo" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:foo" version="3.0"> <xsd:complexType name="Something"> <xsd:sequence> <xsd:element name="Nested" type="foo:NestedType"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="NestedType" /> </xsd:schema> The following XML is valid: <ns:Something xmlns:ns="urn:foo" xsi:type="ns:Something"...

XML Schema: what's the default type of an xsd:attribute?

xml,xsd
In EBUCore schema (http://en.wikipedia.org/wiki/Metadata_standards) there is an attribute named 'version' defined as <attribute name="version" default="1.5"> <annotation> <documentation> The version of the schema for e.g. OAI management.</documentation> </annotation> </attribute> As you see, there is no 'type' defined for it and I wonder, what's the default type for it - anyType, anySimpleType,...

Parse XSD restrictions

c#,xml,visual-studio,xsd,schema
<xs:group name="datosGeneralesComunes"> <xs:sequence> <xs:element name="gravedad"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="1" /> <xs:maxInclusive value="4" /> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="zona"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="1" /> <xs:maxInclusive value="4" /> </xs:restriction> </xs:simpleType>...

Why is my xsd:choice between elements of different types failing?

xml,validation,xsd
I'm trying to validate an XML with XSD, but I can't understand what is wrong with my XSD. XML <?xml version="1.0" encoding="UTF-8"?> <Grades xs:noNamespaceSchemaLocation="grade.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"> <Grade description="Pass"> <LetterGrade>A+</LetterGrade> <GradePoint>4.00</GradePoint> <Percentage>80% and above</Percentage> </Grade> <Grade description="Pass"> <LetterGrade>A</LetterGrade>...

How to remove duplicate XML declaration

java,xml,xsd,jersey,jersey-client
I am receiving following XML response via Jersey client <?xml version="1.0" encoding="UTF-8" standalone="yes"?><aaa><bbb key="Data"><?xml version="1.0" encoding="UTF-8" standalone="yes"?> <my-data xsi:noNamespaceSchemaLocation="MyData.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <data name="abc" uniqueId="4fe95637-a381-4e0c-bf7f-49f794df5f23"> <variable var1="xyz" value="44"/> </data> </my-data> </bbb></aaa> I am saving this as an XML file and getting...

How to use a class customization to resolve conflict when generating jaxb object from xsd

java,xsd,jaxb,ifc
When I run the xjc -d src/ -p com.test IFC2X3.xsd command on following xsd it gives the conflict. .... <xs:element name="IfcCondenserTypeEnum" nillable="true"> <xs:complexType> <xs:simpleContent> <xs:extension base="ifc:IfcCondenserTypeEnum"> <xs:attributeGroup ref="ex:instanceAttributes"> </xs:attributeGroup> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:simpleType name="IfcCondenserTypeEnum"> <xs:restriction base="xs:string">...

C# class serialization mapping

c#,xml,xslt,serialization,xsd
I'm looking for hints, ideas on how to implement and/or change class serialization behavior of following classes in general. Simplified (incomplete) sample classes : [Serializable] public class Choobakka { public string Name { get; set; } public VariableList<Item> Stuff { get; set; } } [Serializable] public class Item { public...

Assertion for attributes with syntax: “string || string || string…” in XSD 1.1

xml,xsd
I have the following really short XML file: <objective name="WriteYourPaper"> <task task="TalkToSupervisor" /> <task task="AcceptPaperNegatively || AcceptPaperPositively" /> <task task="TalkToSupervisor || AcceptPaperNegatively || AcceptPaperPositively"" /> </objective> There can be as many "task" elements as I want inside the objective element. So I think this is a good way to define...

Scalaxb reads from XML, invokes “label”, receives UnsupportedOperationException - why?

xml,scala,xsd,xsd-validation,scalaxb
I'm using scalaxb to convert an instance of XML into another object as follows: val x = xml.XML.load(inputStream) println(x) val ed = scalaxb.fromXML[entityDescriptor.scalaxb.EntityDescriptorType](x) println(ed) When it invokes fromXML, I receive the following exception: scalaxb.ParserFailure: Error while parsing urn:oasis:names:tc:SAML:2.0:protocol urn:oasis:names:tc:SAML:1.1:protocol urn:oasis:names:tc:SAML:1.0:protocol: java.lang.UnsupportedOperationException: class Group does not support method 'label' The XML...

XSD mapping to Java POJOs

java,xml,xsd,jaxb
Let's say I have an XML source from a web service, that I have no control over, with the following structure: <wrapper> <baz>content</baz> <foo> <bar>content</bar> <bar>content</bar> </foo> </wrapper> The corresponding XSD is the following: <xsd:complexType name="wrapper"> <xsd:element name="baz" type="xsd:string"/> <xsd:element name="foo" minOccurs="0" maxOccurs="1"> <xsd:complexType> <xsd:sequence> <xsd:element name="bar" type="xsd:string"...

5 different Objects with the same values to an function

c#,oop,object,xsd
I have created a Structure class with the "XSD.exe" and now I have a short problem: I have 5 different "Classes" in the Structure and all 5 Classes have the same values like this: public partial class Carrier { private string codeField; private string companyField; private string legalNameField; private string...

Create XSD based on root element

java,xml,parsing,xsd
I have a XSD as shown below , i need to extract all the root Elements in the XSD and create a separate XSD for each root element pragmatically in java, is there some framework of java library that can aid me in achieving this. <?xml version='1.0' encoding='windows-1252'?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"...

Get the name of namespace xmlns from xsd file through XmlSlurper/XmlParser

groovy,xsd,xml-parsing
I am trying to fetch the namespace for an xml(xsd) file through Groovy. The Node returned by the XmlParsers, and the GPathResult by XmlSlurper seems to ignore the namespace definitions. As an example: <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified"> trying to fetch the attributes of the rootNode through rootNode.attributes()...

Xml schema regex to not allow white spaces alone

regex,xml,xsd
In xml, i have a tag say <membercode> The regex pattern for the field currently is <xs:pattern value="[a-zA-Z0-9\s]{1,3}" /> The membercode must accept values as follows: 1) "XY" -> pass 2) "XY " -> pass 3) " " -> i need to have this failed. but it is getting passed....

invalid xsd- SAXParseException

xml,xsd
I´m currently working with xsd and tried to define a simple XSD file, for an order with some order-items. But i´m getting a SAXParseException, if i validate the xsd file. Who can see the problem? I can´t get it fixed so far :( <?xml version="1.0" encoding="UTF-8" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element...

Validate optional XML element in XSD

xml,xsd,xml-validation
How would I validate RequiresPaidSubscription only when provided? <xs:element name="RequiresPaidSubscription" minOccurs="0" > <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="True|true|False|false|0|1"/> </xs:restriction> </xs:simpleType> </xs:element> The minOccurs="0" doesn't seem to do anything for me with the above....

cvc-elt.1.a: Cannot find the declaration of element “ear”

java,xml,xsd
I am very inexperienced about xml schemas,xsd files and the validation; and I have been developing a xml file for my project.After running the xml validation class, I have cvc-elt.1.a: Cannot find the declaration of element 'ear' error on the console. This is the xsd file that I use for...

XmlDocument XSD Validation does not find error

c#,xml,validation,xsd,xmldocument
I build my XmlDocument in code. Before returning it I want to validate it against an XSD defined in a file. xmlDocument.Schemas.Add(null, "MySchema.xsd"); xmlDocument.Validate((sender, e) => { if (e.Severity == XmlSeverityType.Error) { // Write error to log } }); There never occurs any error. Although I added an error to...

Defining assertions depending on both attributes and elements in xsd 1.1

xml,xsd
I need to define the following situation in my XSD Schema. This is an example of my XML: <initialization> <stat name="SelfActualization" range="" init="" tickValue="" colorR="" colorG="" colorB=""/> <stat name="Social" range="" init="" tickValue="" colorR="" colorG="" colorB=""/> <staticAction name="Study" > <SelfActualization reqPoints="0" gainedPoints="0" /> <Social reqPoints="0" gainedPoints="0" /> </staticAction> <staticAction name="Greetings" >...

Serialize root element in a namespace, not without a namespace

c#,xml,xsd
I want to get the following XML while using XmlSerializer: <?xml version="1.0"?> <GetProfileRequest xmlns="urn:veloconnect:profile-1.1"> </GetProfileRequest> But when I serialize, I get the following XML: <?xml version="1.0"?> <GetProfileRequest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> </GetProfileRequest> Code for serialization: GetProfileRequest request = new GetProfileRequest(); XmlSerializer serialize = new...

XML against XSD from file with MinOccurance using XDocument

xml,xsd,linq-to-xml
i use some xsdMarkup string xsdMarkup = @"<?xml version='1.0' encoding='utf-8'?> <xs:schema attributeFormDefault='unqualified' elementFormDefault='qualified' xmlns:xs='http://www.w3.org/2001/XMLSchema'> <xs:element name='catalog'> <xs:complexType> <xs:sequence> <xs:element maxOccurs='unbounded' name='book'> <xs:complexType> <xs:sequence> <xs:element name='authors'> <xs:complexType> <xs:sequence> <xs:element maxOccurs='unbounded' name='author'...

How to define an XML element containing forward slash (/) in XSD?

xml,xsd
I have an element in my Soap request as below. <Destination>abc/xyz</Destination> It is failing XML Schema validation. How can I define it in XSD? I have defined as below and it seems to be not correct: <xs:element name="Destination" type="Destination" minOccurs="1"/> <xs:simpleType name="Destination"> <xs:restriction base="xs:string"> <!-- <xs:pattern value="*/*"/> --> <xs:maxLength value="30"/>...

Deserializing to a subclass problems

c#,xml,xsd,deserialization,xmlserializer
I have been trying to deserialize some XML into a class which is a subclass of another class. When I tried deserializing into the base class it works. However when the class is deserialized to any of the subclasses it will fail. I would like to know why this is...

XSD “one or both” choice does not work with type restriction

xml,xsd
I want to create an XSD where an Item needs to specify at least one identifier, or both, but never none. This works fine in the first moment: <xs:choice> <xs:sequence> <xs:element name="OneIdType"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:maxLength value="50"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="AnotherIdType" type="xs:string" minOccurs="0"/> </xs:sequence> <xs:element name="AnotherIdType" type="xs:string"/> But both...

How to get value of @XmlElement annotation

java,validation,reflection,xsd,annotations
I have made traversal through object graph to pick up all fields and their given annotations and would like to validate domain objects built from the XSDs based on the annotations. However, i got stuck on the @XmlElement as i don't know how to get the value of required attribute....

Tomcat complaining about spring-security-3.1.xsd not matching Spring Security 3.2, but not referencing 3.1 anywhere

java,maven,spring-mvc,spring-security,xsd
The error message: SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [security-config.xml] Offending resource: ServletContext resource [/WEB-INF/spring/app-config.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: You cannot use...

How can I apply a XSLT template to several different elements with the same structure?

xml,xslt,xsd
I have scoured Google and Stack Overflow and have been unable to find an answer to this. So I apologize if this is a duplicate. I have an XML document that has some nested types; however, several repeating elements appear throughout the document all with different names and parents. When...

How to create Xsd so that the XML with parent and child have same xmlns defined

java,xml,xsd
I have a scenario where we need to have a parent xml tag with a namespace on the tag. The child tag which can repeat n number of times also should have the namespace attibute on it as below. How shall i define it in XSD to enforce the namespace...

Defining XML file without its Schema

c#,xml,xsd
I believed that we create XML's Schemas to define the XML elements and its structure. I thought, we must define the XSD before we create a XML file. In other word, xml file without its xsd is meaningless. Today I run this code, XmlWriter XmlWriter = XmlWriter.Create("Test.xml"); XmlWriter.WriteStartDocument(); XmlWriter.WriteStartElement("Users"); XmlWriter.WriteStartElement("User");...

Xml validation against xsd accept wrong xml as valid

java,xml,xsd
I have java code which validate my xml against xsd: public static void main(String[] args) throws Exception { Source xmlFile = new StreamSource(new File("src/main/resources/file.xml")); SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = schemaFactory.newSchema(new Source[] { new StreamSource(new File("src/main/resources/RegTypy.xsd")), new StreamSource(new File("src/main/resources/XopInclude.xsd")), new StreamSource(new File("src/main/resources/RobTypy.xsd")), new StreamSource(new...

Defining mixed element in XSD allowing “nesting”

xml,xsd
I am facing the following problem. I need to create an XSD schema of my XML file. Let's say that I have several "Conversation Objects" nodes: Message End Effect which are simple elements that I am able to describe in my XSD. Then I have a special one called: yesOrNoAnswer...

Validating XML which has '& 'against XSD throws “The entity name must immediately follow the '&' in the entity reference”

java,xml,xsd,sax
I have a xml which contains '&' in the content, and i am trying to validate the xml aganist the xsd using the following code SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = factory.newSchema(new StreamSource(xsd)); Validator validator = schema.newValidator(); validator.validate(new StreamSource(xml)); the code works fine when XML doesnt has a '&',...

Specify unique element in xml

xml,xsd,xsd-validation
Can someone figure out what is wrong with my schema because I can add duplicate PersonID with my schema: <xs:element name="Persons" minOccurs="1" maxOccurs="1"> <xs:complexType> <xs:sequence> <xs:element name="Person" minOccurs="1" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="PersonID" minOccurs="1" maxOccurs="1"> <xs:simpleType> <xs:restriction base="xs:int"> <xs:minExclusive value="0"/> </xs:restriction> </xs:simpleType>...

XML Attributes across schema versions

xml,xsd
I have following case: There are two version of a product: Product v1.0 and Product v1.1 v1.0 has schema which successfully verifies following xml: <Root> <Tag Name="Tag1"> </Root> v1.1 has schema which successfully verifies following xml: <Root> <Tag Name="Tag1" ID="1"> <Root> The new version has a new xml attribute 'ID'...

Wildcard file matching in XML

java,regex,xml,xsd,glob
XML file contains <Wildcard> tag, <Wildcard>r_prior*.obj</Wildcard> I want to access file with name r_prior[0-9].obj , there can be a file r_prior_dummy.obj (which I dont need), but with current code it's taking r_ram_dummy.obj also. Schema code for <Wildcard> : <simpleType name="Wildcard"> <restriction base="string"> <pattern value="[^\\/]+"></pattern> </restriction> </simpleType> I tried putting <Wildcard>r_prior[0-9].obj</Wildcard>,...

How to differentiate elements in an XSD by namespaces

xml,xsd,namespaces,schema
Given the following XML snippet: ... <ns1:Method> <Parameter1 /> <Parameter2 /> </ns1:Method> <ns2:Method> <Parameter3 /> </ns2:Method> ... Is it possible to write an XML Schema definition, that differs the complexType of Method by its namespace, so that multiple different types named Method are possible? In this example the Method element...

org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 122; cvc-elt.1: Cannot find the declaration of element 'beans'

java,xml,spring,spring-mvc,xsd
I am using spring and having an issue My servlet-config.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd...

Converting XSD 1.1 to 1.0 - Validation Error

xml,xsd
When I try to validate this XSD: <xs:group name="ValidityDateGroup"> <xs:annotation> <xs:documentation>Reusable element group to be used where Valid From/Until needs to be captured in xs:date format</xs:documentation> </xs:annotation> <xs:all> <xs:element minOccurs="0" name="ValidFrom" type="xs:date"/> <xs:element minOccurs="0" name="ValidUntil" type="xs:date"/> </xs:all> </xs:group> <xs:complexType name="NameType"> <xs:choice maxOccurs="unbounded" minOccurs="0">...

How check file XML

xml,xsd,xml-parsing,xmlhttprequest,linq-to-xml
I have xml file. I think file is not correct.I check file in validator. I get link: http://validator.w3.org. I get 3 warinngs but document is good. My question is that file correct.Do I must add DOCTYPE. Can you help me.I am green in XML. Can you give me tutorial, books,...

JaxB rename class with duplicate name

java,xml,xpath,xsd,jaxb
I have to use a schema which contains the following snippet where the name object is duplicated. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="param_object_type"> <xs:sequence> <xs:element name="object" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="object" minOccurs="0" maxOccurs="unbounded"> </xs:sequence> </xs:complexType> </xs:sequence> </xs:complexType> </xs:schema> Jaxb was originally...

Return DataTable schema beside data, in web service output

c#,xml,web-services,xsd,asmx
I write a web service using c# and it going to be consumed in a java application. Simply I return a Dataset that has one or more DataTable in it. Output is in XML format. Now the consumer need to have the schema of the output table to know the...

Validate xml if any one element exists in a sequence xsd

xml,xsd
I have the following XSD: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="PaymentSearchRequest"> <xs:complexType> <xs:sequence> <xs:element name="User"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="1" /> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="Password" nillable="false"> <xs:simpleType> <xs:restriction base="xs:string">...

XSD: choice based on the condition of an element

xml,xsd,.net-4.0
I'm trying to come up with an XSD for this kind of XML: <root> <valid> <a>1</a> <b>foo</b> <c>bar</c> </valid> <valid> <a>2</a> <c>bar</c> <d1>baz</d1> </valid> <valid> <a>3</a> <c>bar</c> <d2>baz-restricted</d2> <e>qux</e> </valid> </root> In all elements named valid, each child-element is mandatory. I know I need to make the xs:choice conditional on...

XSD definition for same elements in an XML

xml,xsd
I am trying to come up with an XSD complex type for an XML with these contents <SimpleData name="omsId">46</SimpleData> <SimpleData name="registrationNumber">206-TG-4</SimpleData> <SimpleData name="obstacleType">Antenna</SimpleData> <SimpleData name="signature">OEI</SimpleData> <SimpleData name="state">A</SimpleData> <SimpleData name="maxHeightAGL">75</SimpleData> <SimpleData name="topElevationAMSL">787</SimpleData> In the example above the...

XSD from XML Java Jaxb

java,xsd,namespaces,jaxb
I need to generate in Java the xsd file which using jaxb maven plugin (http://mojo.codehaus.org/jaxb2-maven-plugin/xjc-mojo.html) will produce an XML like the following: <data xmlns = "http://foo.com"> <childData xmlns = "http://bar.com" /> </data> I don't want to edit the jaxb autogenerated classes or something like that. I've already checked similar topics...

There is no Unicode byte order mark. Cannot switch to Unicode

c#,xml,xsd,xmlreader
I am writing a XML validator with XSD Below is what I did, but when I reached the line while (list.Read()) it gives me the error There is no Unicode byte order mark. Cannot switch to Unicode. can anybody help me fix it? public class Validator { public void Validate(string...

XSD none, one, or both

xml,xsd
I searched a whole bunch and couldn't find any questions similar to this before posting. I'm working on creating an XSD and one complexType has these requirements: The element can have neither field The element can have field one If the element has field two it must also have field...

XSD unique element XPath limitations

xml,xpath,xsd,unique
In order to allow an element to appear multiple times but restrict it to element values only being allowed once I'm applying the unique element. I've only got it working in an inefficient manner due to the XPath limitations within XSD 1.0 though. XSD 1.1 is unfortunately not an option...

IF-condition on attributes

xml,xsd
I am creating a simple XML schema for chess game. I don't want pieces that have not been taken to be duplicated, so I used unique. But, the problem is pieces that have been taken and the pieces that have taken those taken pieces are duplicated. So, I want to...

XPath Unqiue Element Not Working

xml,xpath,xsd
Here is my schema: <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="chessGame"> <xs:complexType> <xs:sequence> <xs:element name="pawns" type="pawns" minOccurs="1" maxOccurs="1"/> <xs:element name="knights" type="knights" minOccurs="1" maxOccurs="1"/> <xs:element name="kings" type="kings" minOccurs="1" maxOccurs="1"/> <xs:element name="queens" type="queens" minOccurs="1" maxOccurs="1"/> <xs:element name="rooks"...

Validation error in XML Schema for complexType

xml,xsd,xml-validation
Error: s4s-elt-must-match.1: The content of 'viviendas' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: complextype. Schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns="http://wwww.vivienda.io" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.vivienda.io"> <xs:element name="viviendas"> <xs:complextype> <xs:sequence maxoccurs="unbounded"> <xs:element name="vivienda" minoccurs="1">...

How to check out the sum of integers in a in XSD 1.1

xml,xsd
I have a couple of attributes defined in this way: <xs:attribute name="actor" type="xs:string" use="required"/> <xs:attribute name="percentage" use="required"> <xs:simpleType> <xs:list itemType="xs:integer"/> </xs:simpleType> </xs:attribute> What I need to do is creating an assertion that checks out if the sum of the integers in that list (taking care of the blank spaces) is...

XML schema validation, how to ignore tree inside element

xml,validation,xsd
Considering this xml: <myName myClass="grandfather" name="grandfather_name" transaction="new"> <attributes> <name>test name</name> <description>some stuff for desc</description> <version>the current version</version> </attributes> <myName myClass="father" name="father_name" transaction="new"> <attributes> <name>test name</name> <description>some stuff for desc</description> <version>the current version</version>...

XSD 1.1 assert attribute must be present in document

xml,xsd,xsd-1.1
Using XSD 1.1 is it possible to assert that an attribute exists somewhere else. Example: <root> <someelement> <lookup name="test"/> <bla> <lookup name="tbl2"/> <morebla> <evenmore> <lookup name="tbl2"/> </evenmore> </morebla> </bla> </someelement> <table name="test"> ... </table> <table name="tbl2"> ... </table> </root> How would I assert that the element lookup has a name...

XML Validation with XML-Reader in PHP

php,xml,xsd,xmlreader
I've got errors during validation of a generated XML string. I loaded the XML-String with XML-Reader and assigned the XSD-File for validation. There are object IDs and urls to validate against a pattern of allowed characters. I think the IDs and urls are correct. But why does the validation process...

Generating big enum classes with numbers in enum values JAXB, XJC

java,enums,xsd,jaxb,xjc
I'm trying to generate java classes using XJC and I have the following problem: I'm trying to parse this schema which is a big enum type (bigger than default typesafeEnumMaxMembers). So I use following binding: <jxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" version="2.1"> <!-- Raise theEnumMemberSizeCap limit --> <jxb:bindings > <jxb:globalBindings typesafeEnumMaxMembers="2000"/> </jxb:bindings> </jxb:bindings>...

To pass more than one row value from database to XML

c#,xml,xsd
I want to generate an xml file in the fllowing format. <?xml version="1.0" encoding="utf-8"?> <AutoCount xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.autocountsoft.com/ac_accounting.xsd"> <Product>AutoCount Accounting</Product> <Version>1.5</Version> <CreatedApplication>BApp</CreatedApplication> <CreatedBy>Business Solutions</CreatedBy> <Sales DocNo = 'S0001'>...

exception unmarshalling xml file using jaxb

java,xml,xsd,jaxb
I'm trying to unmarshall an xml file, but I get a binding exception, I'm new to using xml and schemas with java, but from what I can tell, it looks like a problem with the namespaces when it tries to bind the xml to an xsd schema I'm using. I've...

Generate XML file with subnodes from xsd file using c#

c#,xml,xsd
I have a xsd file acount.xsd, using which i created a acount.cs file, using this i created a xml file. I have written these following command in c# for button click to generate the xml file. string PATH = "C:\\Sample.xml"; CreateEmptyFile(PATH); var data = new AutoCount(); data.Product = "AutoCount Accounting";...

Problems using xml validation with xsd schema

java,xml,validation,xsd
It is the first time i'm using xsd to validate an xml document in java and I really can't seem to get this to work. Well, first of all here is my xml document structure, Employees.xml: <?xml version="1.0"?> <x:Employees xmlns:x="urn:Employees"> <Employee id="1"> <name>Some Guy</name> <gender>Male</gender> <role>Java Developer</role> </Employee> <Employee id="2">...

Cannot resolve the name to a(n) 'element declaration' component

java,xsd,compilation,maven-jaxb2-plugin
while compiling maven-jaxb2-plugin I get below error [INFO] --- maven-jaxb2-plugin:0.8.3:generate (default) @ customer-project --- [ERROR] Error while parsing schema(s).Location [ file:....Customer.xsd{12,97}]. org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'ttadcustomer:CustomerApplicationDetail' to a(n) 'element declaration' component. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) at...

Unique for attributes in two elements

xml,xsd
I'm building XML and XML schema for a chess game. There shouldn't be duplicates on position. To solve that, I used unique, so this works for each element but not both together. For example, if I have position "66" for player black's pawn, rook, bishop, then it shows those are...

Validate on an integer or empty

xml,xsd
I have the following xsd element: <xs:element name="Runtime" type="xs:integer" minOccurs="0"/> How would I change it so it accepts a positive integer or empty? <Runtime>1</Runtime> <Runtime></Runtime> <-- This will currently fail --> ...

Specify type for an element that must have at least one child element

xml,xsd,xml-validation
The element elements must contain at least the element element1 or element2, but each of them at most once. For this I've specified the following XML Schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="elements" type ="elementsType"/> <xs:complexType name="elementsType"> <xs:choice> <xs:sequence> <xs:element name="element1" type="xs:string" minOccurs="0"/> <xs:element name="element2"...

XSD to HTML form

java,json,xml,xsd,jaxb
What I want to do: I'm basically trying to create a tool which generates a HTML form where the data can be entered, which gets stored in the corresponding XML file. The HTML form in itself needs to be created with the help of the given XSD. Problems I faced:...

Adding a IF clause to XSL call-template

xml,xslt,xsd
I'm very new to XSL and am trying to edit someone elses code. The xsl calls a template "formatAustralianDate" and returns a number. However, if @created is null it returns NaN days <xsl:call-template name="formatAustralianDate"> <xsl:with-param name="dateValue" select="@Created"/> </xsl:call-template> day(s) is there a way I can test if @Created is null...

How to define an attribute with a format “int,int,int” where each int is in [0,255] , XSD 1.1

xml,xsd
I have a simple element defined in this way: <xs:element name="stat" type="statType" /> <xs:complexType name="statType"> <xs:attribute name="color" use="required"/> </xs:complexType> But I need that the color attribute adhere to the format: "int,int,int" where each int is in the range [0,255]. Can you kindly help me defining it? Thanks in advance!...

XSD for Alternating Elements

xml,xsd
I have the following XML shown below: <?xml version="1.0" encoding="utf-8"?> <main> <bbcor Location="string" Name="string"> <PipeDiameter_INCH>3.1415926535</PipeDiameter_INCH> <InitialPressure_PSI>3335.566</InitialPressure_PSI> <LWISE TotalSection="2"> <DL_FT>535.00</DL_FT> <HL_FT>653.00</HL_FT> <DL_FT>245.98</DL_FT> <HL_FT>395.0</HL_FT> </LWISE> </bbcor> </main> I am trying to make a XSD validator for above file, but...

How to correct XSD so XML validates?

xml,xsd,xml-validation
In my application, I have the XSDs shown below. These are modifications of existing XSDs in my application and they are my starting point. GPSInformation.xsd <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns="aNamespace" elementFormDefault="qualified" targetNamespace="aNamespace" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="gps"> <xs:annotation> <xs:documentation>An instance of this class contains all of the information we want to retrieve...

Jaxb generate classes from xsd:s with common include fails

java,xsd,jaxb
I'm trying to generate classes from a bunch of xsd:s that all include the same common schema which simplified looks something like this: Schema1.xsd: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="namespace"> <xsd:include schemaLocation="common.xsd"/> ..... </xsd:schema> Schema2.xsd: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="namespace"> <xsd:include schemaLocation="common.xsd"/> ..... </xsd:schema> and the common schema does not define a...

How to make it such that order doesnt matter in xsd with maxOccurrence > 1

xml,xsd
I have the following xml, which I'd like to accept: <Movies> <Title> <Platform>Hulu</Platform> <PlatformID>500219855</PlatformID> <Type>Movie</Type> </Title> <Title> <Type>Movie</Type> <Platform>Hulu</Platform> <PlatformID>50019855</PlatformID> <Platform>ITunes</Platform> </Title> </Movies> I am currently using an xs:sequence, but that restricts ordering. I also tried using an xs:all instead, but that only allows a...

How to specify an ordered list in XSD

xml,xsd
I have a list of numbers that need to be ordered. Currently they are in the XML as such: <value_1>0.2</value_1> <value_2>0.4</value_2> <value_3>0.6</value_3> ... <value_N>1.8</value_N> Is there a better way to do this such that it can be well defined in XSD and that the data is returned from a parser...

Datetime value not accepted in XML through c#

c#,xml,xsd
Unable to pass datetime.now value to a node 'createddatetime'. Output xml file discards the node. i used the following code, string PATH = "C:\\Samplex.xml"; CreateEmptyFile(PATH); var data = new AutoCount(); data.Product = "AutoCount Accounting"; data.Version = "1.5"; data.CreatedApplication = "BApp"; data.CreatedBy = "Business Solutions"; data.CreatedDateTime = DateTime.Now; /* this line*/...

Create SQL Server DB from DataSet

c#,sql-server,xml,xsd,dataset
I read xsd and xml file in DataSet, now I want create db from this DataSet foreach (DataTable dt in temp.Tables) { foreach (DataColumn dc in dt.Columns) { //example for one column SqlCommand createtable = new SqlCommand( "create table " + dt.TableName + " (" + dc.ColumnName + " varchar(max))",...

scala match String* generated from xsd with maxOccurs=“unbounded”

scala,xsd,pattern-matching,varargs
I have a xsd with: <xs:complexType name="records"> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="return" type="xs:string"/> </xs:sequence> </xs:complexType> scalaxb generated this code: case class Records(returnValue: String*) I tried this pattern matching: ... match { case Records(ids: String*) => ... Then the compiler error is: ')' expected but identifier found. case Records(ids: String*) =>...

Writing a correspondence between Oracle and XSD data types

xml,oracle,xsd
My task is to create a conversion from Oracle metadata to XSD formatting to ensure correct translation of data from Oracle to XML. To accomplish this I need to provide a correspondence table for the Oracle data types and XSD data types. The following is such a table for numbers....

XSD regular expression restriction on xsd:string

regex,xml,xsd,xml-validation
What would be the regular expression if I want a sequence of integers separated with at least one blank? Something like "123 098"....

XML Validation error: attribute type is abstract

java,xml,xsd
When i am validating my XML with its XSD. its showing "Item type is abstract". Any one know how to use abstract complex type in xml and why this error is being raised. <xs:element name="Items"> <xs:complexType> <xs:sequence> <xs:element name="Item" type="tns:ItemsClass" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType abstract="true" name="ItemsClass"> <xs:group...

xpath to rename single class in crazy hierarchy

java,xpath,xsd,jax-ws,jaxws-maven-plugin
I'm trying to generate classes from wsdl using jaxws-maven-plugin, but I get uncompilable results. The problem is this part of one of the xsds, where you can see that there are nested elements with the same name: <xs:complexType name="TrafficCountsReplyData" abstract="true"> <xs:sequence> <xs:element name="effectiveTrafficWindow" type="common:DateTimeMinutePeriod" minOccurs="1" maxOccurs="1"/> <xs:element name="flows" minOccurs="0" maxOccurs="1">...

XML values of the same attribute in different elements cannot repeat

xml,xsd
In my C# application I use an XSD file to validate XML files. Is there any way to include in XSD file a prevention from repeating values of the Reference_number attribute in different elements? <?xml version="1.0" encoding="utf-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Items"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="Item"> <xs:complexType> <xs:sequence>...

How to generate xml sample form xsd with XMLSchema:sequence

xml,xsd
How to create xml sample from xsp with contains XMLSchema:sequence ? I tried http://www.xsd2xml.com/ but it returns error Error!!! The 'http://www.w3.org/2001/XMLSchema:sequence' element is not supported in this context. instead of sample. Original xsd has types in separate files and I copied those types to end of this xsd as Maybe...

Custom XSD simple type to accept date or dateTime

xml,xsd,xsd-validation
I have an XML element <ManufactureDate>20150316</ManufactureDate> that uses a custom date type element, <xs:simpleType name="CustomDate"> <xs:restriction base="xs:string"> <xs:maxLength value="8"/> <xs:whiteSpace value="collapse"/> <xs:pattern value="\d*"/> </xs:restriction> /xs:simpleType> for validation, but now I want another element to have the same CustomDate datatype but to give an input with time like below <ExpirationDate>20150316T15:53:00</ExpirationDate> Does...

XML validation using XSD (regex) with “|” operator (Notepad++ plugin)

regex,xml,xsd,notepad++,xsd-validation
I am using following not very strict XSD validation (regular expression) to check if a string contains https or relative URLs and not http. <xs:attribute name="src"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="(.{4}[^:].*)|(.{1,4})"/> </xs:restriction> </xs:simpleType> </xs:attribute> Sample XML: Succeeds (suppose to fail) <?xml version="1.0" encoding="UTF-8"?><html src="http://www.stackoverflow.com" /> Succeeds (as expected) <?xml version="1.0"...

XmlReader always validates a Xsd file against another Xsd file as valid

c#,xml,xsd,xmlreader,xml-validation
I've got strange behaviour of the XmlReader. When using it for validation Xml against Xsd everythink works fine and how I expect. But when I try validate a Xsd file against another Xsd, it throws no validation exception. For better explenation of my use case: I have an application where...

Can XSD extension re-order elements?

xml,xsd,schema
I want to extend a type in an XML Schema, say like this: <complexType name="alienInfo"> <complexContent> <extension base="personalInfo"> <sequence> <element name="planet" type="xsd:string"/> </sequence> </extension> </complexContent> </complexType> where <complexType name="personalInfo"> <sequence> <element name="name" type="xsd:string" /> <element name="age" type="xsd:int" /> </sequence> </complexType> But I want to change the order of the constituent...

Creating xsd document from file download

python,amazon-s3,xsd,lxml
I am trying to load an xsd document that is stored on s3. It gives me the following err >>> from lxml import etree >>> xsd_url = 'https://s3-us-west-1.amazonaws.com/premiere-avails/movie.xsd.xml' >>> node=etree.fromstring(requests.get(xsd_url).text) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "lxml.etree.pyx", line 3092, in lxml.etree.fromstring (src/lxml/lxml.etree.c:70473) File "parser.pxi",...

Add multiple elements in XML

xml,xsd
Here i have my XML Schema. I'm trying to determine whether Family_Client will allow multiple clients as the Family table may have multiple family members. <xsd:element name="Nzfsg_Families" > <xsd:complexType> <xsd:sequence> <xsd:element name="Family" minOccurs="1" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="FamilyID" type="xsd:int" minOccurs="1" maxOccurs="1"/> <xsd:element name="PostalAddress" minOccurs="0"> <xsd:complexType> <xsd:sequence>...

Xsd Schema Namespace

c#,xml,xsd,namespaces
Please consider below PspShoppingCartServiceRequest.Xsd <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:tns="http://www.example.com" elementFormDefault="qualified" targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:common="http://www.example.com/common" <xs:import namespace= "http://www.example.com/common" schemaLocation="common.xsd" /> <xs:element name="PspShoppingCartServiceRequest" type="tns:PspShoppingCartServiceRequest" /> <xs:complexType...

Case-insensitive regex in XSD

regex,xsd
Is there a better way to do the following? <xs:restriction base="xs:string"> <xs:pattern value="hulu|Hulu|netflix|Netflix"></xs:pattern> </xs:restriction> Basically I want a case-insensitive match on the word....

Python 2.7 Etree/lxml minimizing [duplicate]

python,xsd,formatting,lxml
This question already has an answer here: Close a tag with no text in lxml 3 answers Im using lxml/Etree to parse and write to XSD documents. I have the basic structure tree = ET.parse('file.xsd') # do stuff tree.write('output.xsd') But tags get minimized in some instances, for example: <Cars>...

xsd:complexType after xsd:attribute declarations yields error

xml,vb.net,visual-studio-2010,xsd,xml-validation
I have the following XSD: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="urn:com.xxxxx.xxx" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:com.xxxxx.xxx"> <xsd:element name="Stuff_EXT" type="DT_Analyse_EXT"/> <xsd:complexType name="Stuff_EXT"> <xsd:annotation> <xsd:documentation xml:lang="EN">Data Type Response</xsd:documentation> </xsd:annotation> <xsd:sequence> <xsd:element name="Res"> <xsd:complexType> <xsd:sequence>...

C# Validate DataSet filled with DGV data as XML

c#,xml,validation,datagridview,xsd
I want to make a "Save as" button which will validate data from dataGridView with .xsd XML schema before saving it as an XML file. The idea was to save DataTable filled with DGV data as an XML, validate it with .xsd and delete it if the file is valid...

Well-formed vs validated documents [duplicate]

xml,xsd,dtd,relaxng
This question already has an answer here: Is there a difference between 'valid xml' and 'well formed xml'? 14 answers I have a short question. Why XML files should be validated and not just well-formed? I looked at several places for an answer to this question but I have...

xsd restrict children to children of another complexType

xml,validation,xsd,schema
Is it possible to restrict the children of an complexType to exist in the children of another complexType. for example <xs:element name="people"> <xs:complexType> <xs:sequence> <xs:element name="person" type="personType" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="companies"> <xs:complexType> <xs:sequence> <xs:element name="company" type="companyType" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType>...

Large number failing validation as type xs:integer

xml,xsd,xml-dsig
If I try and validate the following XML: <Signature xmlns="http://www.w3.org/2000/09/xmldsig#"> <SignedInfo> <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /> <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /> <Reference URI="#Id-6fa82551-828a-4d41-ab07-02f6887e32a1"> <Transforms> <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /> </Transforms> <DigestMethod...

How do I generate xsd from dataset.xsd in Visual Studio

c#,xml,visual-studio-2010,xsd,xsd.exe
Using Visual Studio 2010 in a generic C# project, I've created a DataSet (DataSet1.xsd) and dragged my table onto it. I can see the table in the designer view. I want to see the raw .xsd file based on this DataSet. I don't want to write the .xsd by hand,...

Regular Expression in schema validation

java,regex,xml,validation,xsd
I need an xml schema, which validates an empty node and a node with 8 digits to true. So I defined an XML-Schema with the following simple type: <xs:simpleType name="LeererStringOder8Zeichen"> <xs:restriction base="xs:string"> <xs:pattern value="(^$|\d{8})"/> </xs:restriction> </xs:simpleType> I have tried this regular expression using java.util.regex and the internal RegularExpression-class from Xerces....

Set XSD duplicate constraint at document-level

xml,xsd,xml-validation
I have the following XML: <Movies> <Title> <Platform>Hulu</Platform> <PlatformID>50019855</PlatformID> <!-- Reject xml based on duplicate PlatformID --> <UnixTimestamp>1431892827</UnixTimestamp> </Title> <Title> <Platform>Hulu</Platform> <PlatformID>50019855</PlatformID> <!-- Reject xml based on duplicate PlatformID --> <UnixTimestamp>1431892127</UnixTimestamp> </Title> </Movies> The following XSD validates,...

Allow multiple occurrences of unordered XML elements via XSD

xml,xsd
How would I write an XSD that would validate the following two XML documents? 1 <Credits> <Director>Movie</Director> <Director>Movie</Director> <Director>Movie</Director> <Producer></Producer> <Producer></Producer> <Actor>Jules Verne</Actor> <Producer></Producer> <Actor>Jules Verne</Actor> <Actor>Jules Verne</Actor> </Credits> 2 <Credits> <Actor>Jules Verne</Actor>...

XSD restrictions - whiteSpace “replace”, but spaces not allowed

xml,xsd,xsd-validation
What happens when whitespace is put into a message that follows the following XML Schema? <xs:whiteSpace value="replace"/> <xs:pattern value="[\-\*0-9A-Z]{12}"/> Would the whitespace be replaced with spaces, and then it fail validation? Or would something else happen?...