NOTA : xpp est le namespace utilisé par défaut, mais on peut le changer grâce à l'option -n, --namespace.
Pour plus de détails sur chacune des balises, cliquez sur le lien propre à chacune.
<xpp:define name="NAME">...</xpp:define> : définition d'une macro de nom NAME.<xpp:expand select="NAME"/> : expansion de la macro de nom NAME.<xpp:expand href="FILENAME"/> : expansion du contenu du fichier de nom FILENAME.<xpp:ifeq select="NAME" value="VALUE">...</xpp:ifeq> : le contenu de cette balise n'est pris en compte que si la variable de nom NAME vaut VALUE.<xpp:bloc>...</xpp:bloc> : cette balise n'a aucun effet en elle-même, mais sert à améliorer la présentation et est requise dans certaines circonstances par certaines des balises ci-dessus.
Fichier common.xcf :
<xpp:bloc> <xpp:define name="LinuxURL"> <xpp:bloc>linuxfr.org</xpp:bloc> </xpp:define> <xpp:define name="WindowsURL"> <xpp:bloc>windowsfr.org</xpp:bloc> </xpp:define> <xpp:define name="Linux"> <xpp:bloc> <xpp:define name="Directory"> <xpp:bloc>/home/dupond/</xpp:bloc> </xpp:define> <xpp:define name="RootURL"> <xpp:expand select="LinuxURL"/> </xpp:define> </xpp:bloc> </xpp:define> <xpp:define name="Windows"> <xpp:bloc> <xpp:define name="Directory"> <xpp:bloc>c:\Documents\Dupond\</xpp:bloc> </xpp:define> <xpp:define name="RootURL"> <xpp:expand select="WindowsURL"/> </xpp:define> </xpp:bloc> </xpp:define> <xpp:ifeq select="OS" value="Linux"> <xpp:expand select="Linux"/> </xpp:ifeq> <xpp:ifeq select="OS" value="Windows"> <xpp:expand select="Windows"/> </xpp:ifeq> <SomeFile> <xpp:expand select="Directory"/> <xpp:bloc>SomeFile</xpp:bloc> </SomeFile> <OtherFile> <xpp:expand select="Directory"/> <xpp:bloc>OtherFile</xpp:bloc> </OtherFile> <SomeURL> <xpp:bloc>http://</xpp:bloc> <xpp:expand select="RootURL"/> <xpp:bloc>/something</xpp:bloc> </SomeURL> </xpp:bloc>
Fichier linux.xcf :
<?xml version="1.0" encoding="ISO-8859-1"?> <Configuration> <xpp:set name="OS" value="Linux"/> <xpp:expand href="common.xcf"/> </Configuration>
Fichier windows.xcf :
<?xml version="1.0" encoding="ISO-8859-1"?> <Configuration> <xpp:set name="OS" value="Windows"/> <xpp:expand href="common.xcf"/> </Configuration>
En lançant la commande expp linux.xcf, on obtient le résultat suivant :
<?xml version="1.0" encoding="ISO-8859-1"?> <Configuration> <SomeFile>/home/dupond/SomeFile</SomeFile> <OtherFile>/home/dupond/OtherFile</OtherFile> <SomeURL>http://linuxfr.org/something</SomeURL> </Configuration>
En lançant la commande expp windows.xcf, on obtient le résultat suivant :
<?xml version="1.0" encoding="ISO-8859-1"?> <Configuration> <SomeFile>c:\Documents\Dupond\SomeFile</SomeFile> <OtherFile>c:\Documents\Dupond\OtherFile</OtherFile> <SomeURL>http://windowsfr.org/something</SomeURL> </Configuration>