It is also possible to specify an absolute location, but beware that you must use URL syntax, not Path syntax.
Because I needed it recently for a unit test, today I will show you how you can validate an XML against a XSD schema in Nav. Object.’mscorlib, Version=188.8.131.52, Culture=neutral, Public Key Token=b77a5c561934e089′Validate XMLwith XSD(XMLPath : Text; XSDPath : Text) XMLDoc := XMLDoc.
In this case, the XML Schema is to be found in the same folder as the XML Document.It uses XML Events, which is a representation of an XML document that is similar to SAX Events. The producer drives the SAX events and the consumer drives the XML events.The streaming validator shares software with the older schema validator and derives most functionality from it.This means that you can use the same XML processing components in Stylus Studio®'s award-winning XML IDE that you use in your real-world production environment.A screenshot of XSD validation in Stylus Studio® is shown below: (click to enlarge) Validating an XML document in Stylus Studio® is easy, just load an XML document, associate an XSD, click on the Validate XML button (the green checkmark) then select a validating XSD processor to use.We have the following XSD schema: And we need to validate the below XML file against it: First, we need to convert ‘False’ into ‘false’ and ‘,’ from decimal into ‘.’. For this I created the following function which receives as arguments the Initial file path (original file with invalid values) and the Resulted file path. Regex.’System, Version=184.108.40.206, Culture=neutral, Public Key Token=b77a5c561934e089′Replace Decimals With Comma To Be With Point(Initial XMLFile Path : Text; Result XMLFile Path : Text) //convert 'False' into 'false' String Builder := String Builder. Read All Text(Initial XMLFile Path)); String Builder. Xml, Version=220.127.116.11, Culture=neutral, Public Key Token=b77a5c561934e089′ Schemas Dot Net System. The function creates the Resulted file which can be validated against the XSD schema: Local Variables: My File Dot Net System. File.’mscorlib, Version=18.104.22.168, Culture=neutral, Public Key Token=b77a5c561934e089′ String Builder Dot Net System. String Builder.’mscorlib, Version=22.214.171.124, Culture=neutral, Public Key Token=b77a5c561934e089′ Reg Ex Dot Net System. Replace('False','false'); //convert decimals with comma to be with point Reg Ex := Reg Ex. The Resulted XML file (“test.xml”) generated by the above function looks like this: Next I created the function that validates a XML file against a XSD Schema: Local Variables: XMLDoc Dot Net System. This event context is then given to the streaming validator, so that it is able to request events from the producer.Passing in a schema DOM to the events, the document is valid.Stylus Studio® allows you to easily validate XML documents against any data model defined using W3C XSD, using any major XSD Validator, including MSXML 3.0, MSXML 4.0, MSXML 6.0, Xerces-J, Xerces-C, Microsoft System.XML (1.0 and 2.0), XSV, the Saxonica XSD Validator and all other validating XSD parsers (or DTD parsers).