{"id":37021449,"url":"https://github.com/xs-parser/xs-parser","last_synced_at":"2026-01-14T02:32:07.014Z","repository":{"id":36957782,"uuid":"480935259","full_name":"xs-parser/xs-parser","owner":"xs-parser","description":"xs-parser is a Java software library that represents the object model described in the W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures and Part 2: Datatypes.","archived":false,"fork":false,"pushed_at":"2025-10-27T22:16:09.000Z","size":918,"stargazers_count":4,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-28T00:14:17.396Z","etag":null,"topics":["xml","xml-schema","xsd","xsd-parser"],"latest_commit_sha":null,"homepage":"https://github.com/xs-parser/xs-parser","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xs-parser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-04-12T18:51:46.000Z","updated_at":"2025-07-21T17:20:41.000Z","dependencies_parsed_at":"2023-12-03T08:23:14.489Z","dependency_job_id":"97829fe3-9718-4662-ab9d-b27d8384ccfd","html_url":"https://github.com/xs-parser/xs-parser","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/xs-parser/xs-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xs-parser%2Fxs-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xs-parser%2Fxs-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xs-parser%2Fxs-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xs-parser%2Fxs-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xs-parser","download_url":"https://codeload.github.com/xs-parser/xs-parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xs-parser%2Fxs-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["xml","xml-schema","xsd","xsd-parser"],"created_at":"2026-01-14T02:32:06.238Z","updated_at":"2026-01-14T02:32:06.999Z","avatar_url":"https://github.com/xs-parser.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Description\n\n`xs-parser` is a Java software library that represents the object model described in the [W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures](https://www.w3.org/TR/xmlschema11-1/) and [Part 2: Datatypes](https://www.w3.org/TR/xmlschema11-2/).\n\n![Build](https://github.com/xs-parser/xs-parser/workflows/Build/badge.svg)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=xs-parser_xs-parser\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=xs-parser_xs-parser)\n[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=xs-parser_xs-parser\u0026metric=bugs)](https://sonarcloud.io/dashboard?id=xs-parser_xs-parser)\n[![Maintainability](https://sonarcloud.io/api/project_badges/measure?project=xs-parser_xs-parser\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=xs-parser_xs-parser)\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=xs-parser_xs-parser\u0026metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=xs-parser_xs-parser)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=xs-parser_xs-parser\u0026metric=security_rating)](https://sonarcloud.io/dashboard?id=xs-parser_xs-parser)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xs-parser_xs-parser\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=xs-parser_xs-parser)\n[![License](https://img.shields.io/github/license/xs-parser/xs-parser?label=License\u0026logo=github)](https://github.com/xs-parser/xs-parser/blob/main/LICENSE.md)\n\n## Goals\n\n`xs-parser` aims to reduce the mysticism surrounding the complexity of the XSD 1.1 specification by providing users with direct access to the XSD properties.\n\nDue to the complex structure of XML schema documents and the potential variety of the structure of schemas, there is no preference for any particular schema component or structure. Therefore, `xs-parser` only provides the properties described in the XSD 1.1 specification.\n\nUnlike other software libraries that attempt to model XML schema documents, `xs-parser` does not sugarcoat the complexity inherent to the XSD 1.1 specification, but in returns offers a high level of fidelity to the specification. Another added benefit of this approach is that developers who are familiar with the XSD 1.1 specification may quickly adopt this library into their development tool chains.\n\n# Requirements\n\n`xs-parser` requires Java 8 or later and has no third-party dependencies.\n\nIf Saxon, i.e. `net.sf.saxon:Saxon-HE`, version 9+ is detected on the classpath at runtime, then it is used as the XPath, XQuery, and XSLT engine.\nWhen not detected, XSLT and XQuery evaluation are disabled and the XPath engine defaults to the JAXP XPath 1.0 implementation provided by the Java Platform.\n\n[Chameleon inclusion](https://www.w3.org/TR/xmlschema11-1/#chameleon-xslt), [`xs:override`](https://www.w3.org/TR/xmlschema11-1/#override-xslt), and [`xs:redefine`](https://www.w3.org/TR/xmlschema11-1/#modify-schema) are implemented with XSLT templates, and are therefore non-functional when Saxon is not present on the classpath.\n\n# Usage\n\n`build.gradle`\n\n```groovy\nplugins {\n\tid 'java'\n}\n\nrepositories {\n\tmavenCentral()\n}\n\ndependencies {\n\timplementation 'io.github.xs-parser:xs-parser:3.2'\n}\n```\n\n-----\n\n`Runner.java`\n\n```java\nimport java.io.File;\nimport xs.parser.*;\n\npublic class Runner {\n\n\tpublic static void main(final String[] args) throws IOException {\n\t\tfinal Schema schema = new Schema(new File(\"/path/to/schema.xsd\"));\n\t\tschema.typeDefinitions().forEach(t -\u003e\n\t\t\tSystem.out.println((t instanceof ComplexType ? \"Complex\" : \"Simple\")\n\t\t\t\t\t+ \"Type definition: \" + t.name()));\n\t\tschema.attributeDeclarations().forEach(a -\u003e\n\t\t\tSystem.out.println(\"Attribute declaration: \" + a.name()));\n\t}\n\n}\n```\n\n## Equals and HashCode\n\nThe classes of `xs-parser` do not override `equals()` or `hashCode()`. Use reference equality, `==`, instead. Consider the following code and schema:\n\n```xml\n\u003cxs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\u003e\n\t\u003cxs:complexType name=\"A\" /\u003e\n\t\u003cxs:complexType name=\"B\" \u003e\n\t\t\u003cxs:sequence\u003e\n\t\t\t\u003cxs:element name=\"E\" /\u003e\n\t\t\u003c/xs:sequence\u003e\n\t\u003c/xs:complexType\u003e\n\t\u003cxs:element name=\"E1\" type=\"A\" /\u003e\n\t\u003cxs:element name=\"E2\" type=\"B\" /\u003e\n\u003c/xs:schema\u003e\n```\n\nwhere `/path/to/schema.xsd` contains the above schema.\n\n```java\nfinal Schema schema = new Schema(new File(\"/path/to/schema.xsd\"));\nfinal TypeDefinition a = schema.typeDefinitions().getFirst();\nSystem.out.println(a.baseTypeDefinition() == ComplexType.xsAnyType()); // Prints: true\nfinal Element e1 = schema.elementDeclarations().getFirst();\nSystem.out.println(e1.name());                                         // Prints: E1\nSystem.out.println(e1.typeDefinition() == a);                          // Prints: true\nfinal Element e2 = schema.elementDeclarations().getLast();\nSystem.out.println(e2.name());                                         // Prints: E2\nfinal TypeDefinition b = schema.typeDefinitions().getLast();\nSystem.out.println(e2.typeDefinition() == b);                          // Prints: true\n```\n\n## Execution Model\n\nAlmost all evaluations in `xs-parser` are lazy, accomplished through a deferred execution model. The `Schema` constructor does not do anything more than load the DOM of the file as well as a few sanity checks to ensure that what was provided looks roughly like an actual schema. The definitions and declarations of the schema are not parsed until they are needed.\n\n## XSD Datatypes Mapping\n\nXSD Primitive Datatypes | Java class\n-- | --\n`xs:string`, `xs:duration`, `xs:dateTime`, `xs:time`, `xs:date`, `xs:gYearMonth`, `xs:gYear`, `xs:gMonthDay`, `xs:gDay`, `xs:gMonth`, `xs:hexBinary`, `xs:base64Binary`, `xs:anyURI` | `java.lang.String`\n`xs:boolean` | `java.lang.Boolean`\n`xs:decimal`, `xs:float`, `xs:double` | `java.math.BigDecimal`\n`xs:QName`, `xs:NOTATION` | `javax.xml.namespace.QName`\n\nXSD Other Built-in Datatypes | Java class\n-- | --\n`xs:normalizedString`, `xs:token`, `xs:language`, `xs:NMTOKEN`, `xs:NMTOKENS`, `xs:Name`, `xs:NCName`, `xs:ID`, `xs:IDREF`, `xs:IDREFS`, `xs:ENTITY`, `xs:ENTITIES`, `xs:yearMonthDuration`, `xs:dayTimeDuration`, `xs:dateTimeStamp` | `java.lang.String`\n`xs:integer`, `xs:nonPositiveInteger`, `xs:negativeInteger`, `xs:long`, `xs:int`, `xs:short`, `xs:byte`, `xs:nonNegativeInteger`, `xs:unsignedLong`, `xs:unsignedInt`, `xs:unsignedShort`, `xs:unsignedByte`, `xs:positiveInteger` | `java.lang.BigInteger`\n\n## XPath \u0026 XQuery\n\n```java\nfinal var schema = new xs.parser.Schema(new java.io.File(\"/path/to/schema.xsd\"));\nfinal var root = xs.parser.x.NodeSet.of(schema);\n\n// Performs the XPath evaluation for the root schema and all imported or included schemas\nfinal var allSchemas = root.xpath(\"fn:collection()/xs:schema\");\n\n// Gets all xs:complexType name attributes\n// Note: XPath and XQuery usage can be mixed\n// However, Saxon-HE must be on the classpath to use XQuery\nfinal var complexTypeNames = allSchemas.xquery(\"xs:complexType\").xpath(\"@name\");\n\n// Only the /path/to/schema.xsd schema file is evaluated\n// Will not execute the given XPath for any imported or included schemas\nfinal var rootSchema = root.xpath(\"/xs:schema\");\n\n// Gets all xs:simpleTypes in the /path/to/schema.xsd file\nfinal var simpleTypes = rootSchema.xpath(\"xs:simpleType\");\n\nSystem.out.println(\"xs:complexType size: \" + complexTypeNames.size());\nSystem.out.println(\"xs:simpleType size: \" + simpleTypes.size());\n\n// The split() method creates a new single-element NodeSet for every element\ncomplexTypeNames.split().forEach(name -\u003e\n\tSystem.out.println(\"Name: \" + name.getStringValue()));\n// The stream() method iterates over the underlying org.w3c.dom.Node elements\nsimpleTypes.stream().forEach(node -\u003e\n\tSystem.out.println(\"Name: \" + node.getAttributes().getNamedItemNS(null, \"name\")));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxs-parser%2Fxs-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxs-parser%2Fxs-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxs-parser%2Fxs-parser/lists"}