Added sample XSD schema (#163)

Due to some errors with namespaces and XSD schema simplified sample XML for that tool.

Co-authored-by: widlam <mikolaj.widla@gmail.com>
Reviewed-on: #163
Reviewed-by: Adam Bem <bema@noreply.example.com>
Co-authored-by: Mikolaj Widla <widlam@noreply.example.com>
Co-committed-by: Mikolaj Widla <widlam@noreply.example.com>
This commit is contained in:
2023-05-08 10:13:10 +02:00
committed by Adam Bem
parent 71bbe668f6
commit 21f5911b1c
5 changed files with 91 additions and 11 deletions

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<library>
<libraryName>City library</libraryName>
<libraryID>345123</libraryID>
<readerList>
<person>
<readerID>7321</readerID>
<name>Adam</name>
<surname>Choke</surname>
</person>
<person>
<readerID>5123</readerID>
<name>Lauren</name>
<surname>Wong</surname>
</person>
</readerList>
<bookList>
<book>
<bookID>6422</bookID>
<title>Harry Potter</title>
<readerID>7542</readerID>
</book>
<book>
<bookID>1234</bookID>
<title>Macbeth</title>
<readerID>5123</readerID>
</book>
<book>
<bookID>9556</bookID>
<title>Romeo and Juliet</title>
</book>
</bookList>
</library>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
targetNamespace="">
<xsd:element name="library">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element minOccurs="0" name="libraryName" type="xsd:string" />
<xsd:element minOccurs="0" name="libraryID" type="xsd:int" />
<xsd:element minOccurs="0" name="readerList">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="person">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element minOccurs="0" name="readerID" type="xsd:int" />
<xsd:element minOccurs="0" name="name" type="xsd:normalizedString" />
<xsd:element minOccurs="0" name="surname" type="xsd:normalizedString" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element minOccurs="0" name="bookList">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="book">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element minOccurs="0" name="bookID" type="xsd:int" />
<xsd:element minOccurs="0" name="title" type="xsd:string" />
<xsd:element minOccurs="0" name="readerID" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

View File

@@ -84,6 +84,21 @@ function fillDefaultXML(element) {
}
}
function fillDefaultXSD(){
const serverAddress = window.location.protocol + "//" + window.location.hostname + ":8086";
fetch(serverAddress + "/assets/samples/sampleXSD.xsd")
.then( response => response.text() )
.then( (XSDSchema) => {
document.getElementById('transformArea').value = XSDSchema;
} )
fetch(serverAddress + "/assets/samples/sampleXMLForXSD.xml")
.then( response => response.text() )
.then( (XMLSample) => {
document.getElementById('xmlArea').value = XMLSample;
} )
}
/**
* The `fillDefaultXSLT()` function fetches a default XSLT template from the server and sets the value of the element with id "transformArea" to the fetched template.

View File

@@ -36,7 +36,7 @@
<button class="action-button active" id="prettyXMLButton" style="padding: 3px 10px;"
onclick="performFormatRequest('prettify', true, 'xmlArea', 'xmlArea')">Format XML</button>
<button class="action-button active" id="defaultXMLButton" style="padding: 3px 10px;"
onclick="fillDefaultXML(this)">Insert default XML</button>
onclick="fillDefaultXSD(this);">Insert default XML/XSD</button>
</div>
</div>