| by SuperBonBon |
|
XML basics
What is XML > A few rules > A few examples taken from JAFS > How to verify a document ? > Still lost ?
What is XML
XML is a markup language derivated from SGML, so it is only a language based on tags with very few syntax rules. XML allows you to structure the information with tag names. JAFS uses its own tag set ( or grammar ) for all its configuration files.
Documents are said to be :
- well formed : when they follow the XML syntax rules.
- valid : when they match a grammar defined in a DTD (Document Type Definition) or XML schema file.
You can edit XML files with a simple text editor such as Notepad under windows or VI under Unix.
A few rules
-
An XML document must always start with the following declaration
<?xml version="1.0"?> -
All non empty tags must have an opening and a closing tag
<some-tag>content</some-tag>a closing tag starts as you can see with "</"
-
An empty tag ends with "/>"
<some-empty-tag/> -
The tag can contains either some data or other tags :
<some-tag> data <other-empty-tag/> </some-tag> -
A tag can have attributes
<some-empty-tag some-attribute="attribute value"/> -
The top level tag is named the document root
<root-tag> <a-child-tag/> </root-tag> -
Comments are used within <!-- -->
<root-tag> <!-- a comment inside the tag --> </root-tag>
A few examples taken from JAFS
SSL configuration taken from service_config.xml
<ssl-settings>
<store-settings name="default">
<key-store password="somePassword" type="jks">
<path> ../config/ssl/serverKeyStore.jks</path>
</key-store>
<cacerts-store password="somePassword" type="jks">
<path>../config/ssl/serverCACerts.jks</path>
</cacerts-store>
<crls reload-time="10">
<crl location="http://www.someServer.com/someCRL.crl" name="MyFirstCRL"/>
<crl location="http://www.someOtherServer.com/someCRL.crl" name="MyOtherCRL"/>
</crls>
</store-settings>
</ssl-settings>
How to verify a document ?
To make sure that a configuration file is "well formed" after an edition, try opening it with your favorite Internet browser, if you get an error message, it means that you've done something wrong, your browser should give you the line number where the error is located and a detailed error message
Wrong configuration file XML syntax after edition, here the 'sslSettings' tag is not closed correctly :

Looks better after correction :

Still lost ?
If you're still lost with XML you can find tutorials at here or here.








