![]() |
![]() |
![]() |
![]() |
![]() |
A modular document is a document which not only has its own content but which also includes elements contained in other documents.
Let's say you want to add the same copyright information at the bottom of all the XHTML pages you create. The first step is to author the copyright information in a separate document we'll call Copyright.html. The second step is to include this copyright information at the bottom of the XHTML page created during this tutorial.
Use File|New and this time choose XHTML|Div (part of a modular document) as the document template.
This template is a div (a generic container) containing a p. Using Edit|Replace, replace the p by an address element and then type the copyright information. (The copyright sign © has been inserted using the Characters tool.)
Using Edit|Insert Before, insert a hr (horizontal rule) before the address to visually separate the copyright information from the body of the XHTML page.
Using File|Save As (or File|Save which behaves like File|Save As for a new document), save this document as Copyright.html in a place where it can be shared by all the XHTML pages you'll create.
The procedure to do this is very simple. It is similar to copying an element in a document and pasting it in another document:
Now let's apply this procedure to our example:
Click on OK.
The XHTML page now looks like this.
Notice that the copyright information inserted at the bottom of the page is displayed with a light gray background. This is used to indicate that this part of the document has been included from an other document and that,consequently, it cannot be edited in this window.
Click anywhere inside the copyright information and try to type some text: no characters are inserted. (You can still delete, cut or replace the whole copyright information: it is the div which is not editable not its parent body.)
Also notice that the node path bar displays non-editable nodes using a dimmed color.
At the left of the node path bar, the button with a right arrow switches to the window of the included document. Try it and you'll be able to edit Copyright.html.
Once having Copyright.html in front of you, use the button at the left of the node path bar showing a left arrow to go back to the XHTML page created during this tutorial.
Let's suppose you need to write an article about taxes but you don't want to type directly in your document the values of the different VAT rates used in European countries, because you know that these VAT rates are about to change. Let's say that you already have an XML document detailing these VAT rates.
(In this tutorial, creating the VAT rates document from scratch would be tedious that's why you'll find VATrates.html in XXE_install_dir/doc/user/tutorial/. You'll also find in this directory: Untitled.html, the XHTML page we are trying to create, Copyright.html and xxe.gif. That is, all the files used in this tutorial.)
Add a new p at the end of our XHTML page and type in it ``The VAT rate of France is higher than the VAT rate of Germany.''.
Now we need to use VATrates.html to insert the numerical values of the VAT rates in our new paragraph.
Do the same for the VAT rate of Germany.
The XHTML page now looks like this.
This has worked smoothly because:
Now let's try to insert the whole VAT table in our XHTML page:
After the usual confirmation dialog box, this verbose dialog box is displayed.
Click on No. What does this mean?
Command Copy as Reference allows to copy as a reference any element, including those not having an ID.
Unless the copied reference is a reference to the root element of a document, this means that the copied reference is based on the position of the element as a child of its parent element, on the position of the parent element as a child of the grand-parent element and so on.
This is what we call a hierarchical XPointer. In the above example, it is "VATrates.html#element(/1/2/2)".
Pasting a reference based on a hierarchical XPointer is not safe because if you modify the referenced document, your referencing document may point to an element other than the one for which a reference has been originally pasted.
This is why XXE will warn you each time you'll try to paste a reference based on a hierarchical XPointer.
Note that you'll never get the above dialog box when you'll paste a reference to the root element of a document (example: "Copyright.html") or when you'll paste a reference which exclusively uses an ID to locate the element (example: "VATrates.html#france_vat") because these references are considered to be safe.
Now type this sentence at the end of last added p: ``Note that the VAT rate of France is lower than the VAT rate of Italy.'' and insert the value of the VAT rate of Italy as explained above.
Inserting the VAT rate of France in second sentence is easier because we have already pasted it in our XHTML page. In such case, there is no need to switch to the window displaying VATrates.html:
The XHTML page finally looks like this.
If you save this XHTML page or if you click on the Check Validity icon found at the bottom left of XXE window, you'll find that XXE pretends that the XHTML page is invalid: ID "france_vat" already defined (in fact, the same element is included several times from "file:/opt/xxe/doc/user/tutorial/VATrates.html#france_vat") [cvc-id.2].
You can safely ignore this warning. It is reported when a reference to an external element has been pasted several times in the same modular document. In the case of our example, it is the reference to the external span element containing the VAT rate of France which has been inserted two times.