PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Importing an XSD file into a project
  • Using a description imported into the project
  • Example: Full creation of a file according to the XSD description given in example:
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
WINDEV, WINDEV Mobile and WEBDEV include several functions for handling the XML code. The XML code used must comply with the XML standard. See a documentation specific to XML for more details. See XML for more details.
Versions 15 and later
WINDEV, WEBDEV and WINDEV Mobile allow you to import files in XSD format. An XSD file contains the description of the XML file of the same name. Knowing the structure of an XML document allows you to check the validity of this document. The description language for the content of an XSD document is also in XML format.
An example of XSD file:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="person">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="lastname" type="xsd:string"/>
<xsd:element name="firstname" type="xsd:string"/>
<xsd:element name="dob" type="xsd:date"/>
<xsd:element name="email" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Followed by a valid XML file:
<?xml version="1.0" encoding="UTF-8"?>
<person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="person.xsd">
<lastname>Johnson</lastname>
<firstname>John</firstname>
<dob>1967-08-13</dob>
<email>test@yahoo.com</email>
</person>
New in version 15
WINDEV, WEBDEV and WINDEV Mobile allow you to import files in XSD format. An XSD file contains the description of the XML file of the same name. Knowing the structure of an XML document allows you to check the validity of this document. The description language for the content of an XSD document is also in XML format.
An example of XSD file:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="person">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="lastname" type="xsd:string"/>
<xsd:element name="firstname" type="xsd:string"/>
<xsd:element name="dob" type="xsd:date"/>
<xsd:element name="email" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Followed by a valid XML file:
<?xml version="1.0" encoding="UTF-8"?>
<person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="person.xsd">
<lastname>Johnson</lastname>
<firstname>John</firstname>
<dob>1967-08-13</dob>
<email>test@yahoo.com</email>
</person>
WINDEV, WEBDEV and WINDEV Mobile allow you to import files in XSD format. An XSD file contains the description of the XML file of the same name. Knowing the structure of an XML document allows you to check the validity of this document. The description language for the content of an XSD document is also in XML format.
An example of XSD file:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="person">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="lastname" type="xsd:string"/>
<xsd:element name="firstname" type="xsd:string"/>
<xsd:element name="dob" type="xsd:date"/>
<xsd:element name="email" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Followed by a valid XML file:
<?xml version="1.0" encoding="UTF-8"?>
<person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="person.xsd">
<lastname>Johnson</lastname>
<firstname>John</firstname>
<dob>1967-08-13</dob>
<email>test@yahoo.com</email>
</person>
Importing an XSD file into a project
To import an XSD file into a project:
  1. In the "Project explorer" pane, select "XML descriptions".
  2. Right click and select "Import an XML description file".
  3. Select the XSD file of the description to import.
  4. Validate. The XSD is automatically added into the project explorer (in the "XML description" branch). It is ready to use.
Caution: To operate at run time, the XSD file must not be found in a sub-directory of the project or in a sub-directory of the executable.
Using a description imported into the project
To use the description of the XML document, all you have to do is use the variables automatically generated by the import.
  1. Declare an XML document in the format of the imported description. For example, if the imported description is named 'person':
    cMyDoc is xmlDocument <description="person">

    Note: You can specify the file extension during the declaration. For example:
    cMyDoc is xmlDocument <description="person.xsd">
  2. Initialize the different variables that are included in the description of the XML document. For example, if the document includes the last name and the first name of a person:
    cMyDoc.person.lastname = "MOORE"
    cMyDoc.person.firstname = "VINCE"

    Notes:
    • Each element is separated by a dot ..
    • A help is proposed when entering the names of variables.
    • If the name of an element contains a special character (dash for example), it must be enclosed in simple quotes:
      cMyDoc.person.'id-person' = "ValueId"
  3. Several functions can be used to handle the XSD file in order to validate the description of the XML file:
    Versions 15 and later
    XMLSave
    New in version 15
    XMLSave
    XMLSave
    Saves an XML document in a file.
    Versions 15 and later
    XMLValidDocument
    New in version 15
    XMLValidDocument
    XMLValidDocument
    Validates an XML document from an XSD schema.
    Versions 15 and later
    XMLValidNode
    New in version 15
    XMLValidNode
    XMLValidNode
    Validates an XML node, its children and its attributes from its description in the XSD schema linked to the XML document.

Example: Full creation of a file according to the XSD description given in example:

cMyDoc is xmlDocument <description="person.xsd">

cMyDoc.person.lastname = "Moore"
cMyDoc.person.firstname = "Vince"
cMyDoc.person.dob = "19710211"
cMyDoc.person.email[1] = "vince.moore@mydomain.com"
cMyDoc.person.email[2] = "vince.moore@otherdomain.com"

XMLSave(cMyDoc, fExeDir() + ["\"] + "test.xml")

// Or with an intermediate check:
IF XMLValidDocument(cMyDoc) = True THEN
XMLSave(cMyDoc, fExeDir() + ["\"] + "test.xml")
IF ErrorOccurred = True THEN
Error("Unable to save the XML document", ErrorInfo())
ELSE
Info("OK", fExeDir() + ["\"] + "test.xml")
END
ELSE
Error("The XML document is invalid", ErrorInfo())
END
Minimum required version
  • Version 15
This page is also available for…
Comments
Click [Add] to post a comment