Project | WXT | Basics | Download | Documentation | Samples

Fragments

WXT offers an option that makes it simple to prepare any number of XML-fragments that may be used repeatedly.

You may define fragments in the script, see Fragment .

You may prepare one or more files that describes fragments, see Fragments , and use these fragments simply by using a fragment PI, see Fragment

An fragments file is validated according to the following scheme:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="fragment">
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="xs:string">
                    <xs:attribute name="id" type="xs:string" use="required"/>
                    <xs:attribute name="short" type="xs:string" use="optional"/>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>
    <xs:element name="fragments">
        <xs:complexType>
            <xs:choice maxOccurs="unbounded">
                <xs:element ref="fragment" minOccurs="1" maxOccurs="unbounded"/>
            </xs:choice>
            <xs:attribute name="catalog" type="xs:string" use="optional"/>
        </xs:complexType>
    </xs:element>
</xs:schema>

The relative addresses appearing in the fragments are supposed to be correct relative to the file. This may be changed by the catalog-attribute in the root element fragments.

A sample fragments file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<fragments>
<fragment id="head">
    <![CDATA[
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
    <title><?_wxt fragment id="_name"?></title>
    <link rel="STYLESHEET" href="stdstyle.css"/>
    <link rel="STYLESHEET" href="mathstyles.css"/>
    <script type="text/javascript" src="prototype.js"> </script>
    <script type="text/javascript" src="std.js"> </script>
    ]]>
</fragment>
<fragment id="banner">
    <![CDATA[
    <?_wxt image id="bs-2"?>
    <hr/>
    ]]>
</fragment>
<fragment id="leftcolumn">
    <![CDATA[
    <?_wxt modulemenu summary="no"?>
        <div style="margin-left:20px; margin-top:20px">
        </div>
    ]]>
</fragment>
<fragment id="signature">
    <![CDATA[
    <hr/>
    <div>bs with <?_wxt stamp?></div>
    ]]>
</fragment>
</fragments>