Xvcl Pages; [ Cjos Audience]
Overview
About this document
This document proposes a new xmlproperty command. This command behaves like the set tag, but follows the model of the xmlproperty tag in Apache Ant.
This is a proposal for a change in the XVCL specification. It was written by Gilbert Herschberger (15 November 2007).
Note: Modifying the DTD. Add the xmlproperty tag to the dtd/xvcl.dtd document.
Syntax
<xmlproperty document="model.xml"
[ prefix = "prefix" ]
[ collapse-attributes = "yes" | "no" ]
[ defer-evaluation = "yes" | "no" ]
[ keep-root = "yes" | "no" ] />
Goal
An XML document already contains the settings for generating the source code. Set variables with the xmlproperties command. This command reads variables from an XML document, which is not an x-frame.
Dependency
The xml-property command depends on Xml Bind.
Example: Simple
The following example illustrates how to set variables from an XML document. Variables are defined in property.xml. The xmlproperty command is used to set variables. A list of variables are set.
----- property.xml -----
<?xml version="1.0"?>
<model message="Hello, World!">
<example name="MyExample"/>
</model>
----- spc.xvcl -----
<?xml version="1.0"?>
<x-frame name="spc.xvcl" language="text" outfile="spc.txt">
<xmlproperty document="property.xml"/>
</x-frame>
Results: The following variables are set:
<set var="(message)" value="Hello, World!" deferEvaluation="false"/>
<set var="example(name)" value="MyExample" deferEvaluation="false"/>
xmlproperty command
- document. Name of XML document.
- keep-root. When "yes", the name of the root element is included in variable names. Otherwise, it is not included.
- collapse-attribute. When "yes", dot notation is used for attributes. Otherwise, an attribute name is in parentheses "()".
- prefix. Optional. Used as a prefix for all variable names.
document attribute
This attribute is an expression. It contains the name of an XML document. In the following example, the name of the XML document becomes "property-LOCAL.xml".
<set var="site" value="LOCAL"/>
<xmlproperty document="property-?@site?.xml"/>
The name is either of these:
- Relative. When relative, the location depends upon the location of the x-frame.
- Absolute. When absolute, the location is independent of the x-frame. When a document name starts with a scheme, such as file:, ftp:, http:, https: and x-resource:, it is absolute.
keep-root attribute
This attribute is an expression. When "yes", the name of the root element of an XML document is included in variable names.
With keep-root="yes",'
<set var="model_0(message)" value="Hello, World!"/>
With keep-root="no",' the default,
<set var="(message)" value="Hello, World!"/>
collapse-attribute attribute
This attribute is an expression. When "yes", dot notation is used in a variable name.
With collapse-attribute="yes",'
<set var="example_1.name" value="MyExample"/>
With collapse-attribute="no",' the default,
<set var="example_1(name)" value="MyExample"/>
prefix attribute
This is an expression. When set, all variable names are given a prefix.
<xmlproperty document="property.xml" prefix="property"/>
With a prefix:
<set var="property(message)" value="Hello, World!"/>
<set var="property.example_1(name)" value="MyExample"/>
Without a prefix:
<set var="(message)" value="Hello, World!"/>
<set var="example_1(name)" value="MyExample"/>
id attribute
Within an XML document, use the id attribute.
----- property-LOCAL.xml -----
<?xml version="1.0"?>
<model>
<example id="application" name="MyExample"/>
</model>
With an id attribute:
<set var="application(message)" value="MyExample"/>
Without an id attribute:
<set var="example_1(name)" value="MyExample"/>
Expressions
----- property-EXPR.xml -----
<?xml version="1.0"?>
<model>
<example name="MyExample" description="The ?@example_1(name)? product description."/>
</model>
Result:
<set var="example(name)" value="MyExample"/>
<set var="example(description)" value="The ?@example(name)? product description." deferEvaluation="yes"/>
Nesting
----- property-NEST.xml ----
<?xml version="1.0"?>
<model>
<a>
<b>
<c text="Some text."/>
</b>
</a>
</model>
Result:
<set var="a.b.c(text)" value="Some text."/>
|