With reference and  in rules special elements also can be used;, by means of which it is possible to specify characteristics of processable elements, setting various instructions of formatting for identical elements with various attributes. Specified in <attribute> parameters name and value define{determine} attribute XML which should have the current processable element. For example, in the following fragment all elements with attribute free_lance = "true" will be selected in the target HTML-document with grey color



<rule>

<target-element type = "author">

<attribute name = "free_lance" value = "true">

        </target-element>

<p color = "gray">

<children/>

</p>

</rule>



Kill of elements


One of the most powerful means XSL is the opportunity of sorting and sample of the elements selected from the general{common} tree of elements of the document. For this purpose the element <-elements> is used;, which replaces <children/> in rules, defining{determining} those elements which should be processed during recursive detour. For example, in the following example elements <author> will be processed only:



<rule>

<target-element type = "staff"/>

<div>

<-elements>

<target-element type = "author"/>

</-elements>

</div>

</rule>


The element <-elements> in itself does not define{determine} a pattern of formatting, he only operates job of the analyzer, designating, is similar <children/>, "underlaying" elements. In the resulted example the element <author> should be located inside an element <staff>


That in a pattern to allocate not only own affiliated elements, but also affiliated elements of descendants, i.e. to use some levels of an enclosure, it is necessary to set parameter from = "descendants". If the parameter matters "children", that specifies that the choice should is made from the list of own affiliated elements the attribute from can fall since "children" is a default value.

Rules of styles


As against CSS, in XSL use of cascade style definitions (i.e. it is impossible to use some rules for definition of style of one same element) since such restrictions are entered with recursive algorithm of job of the program - the analyzer is impossible. However use of rules of definition of style (Style Rules) an element allows to compensate this lack somehow.


For definition of a rule of style registration it is necessary to use an element <style-rule>;, which is used just as and <rule>, but the instructions contained in him, do not influence in any way structure of the target document. Therefore all commands inside this rule should be described within the framework of an element <apply.> definition of style for an element <flower> rose </flower> will look here is how, for example;:



<style-rule>

<target-element type = "flower"/>

<apply color = "red"/>

</style-rule>

<rule>

<target-element type = "flower"/>

<div font-style = "italic";>

<children/>

</div>

</rule>


If we have not defined{determined} a rule <rule> in the target document it would not be placed any information since the element <style-rule> only defines{determines} parameters of style registration, not undertaking any other actions.


Also it is necessary to take into account, that the XSL-analyzer uses CSS for definition set by rules <style-rule> style in the target HTML-document, thus giving us an opportunity of use of this powerful means at registration of HTML-pages After processing the fragment resulted in an example in the target document the following elements will be placed:



<div style = " font-style: italic; color: red; "

> rose </div>


One more example:


Styles in format CSS:



issue {font-weight=bold; color=blue;}

.new {font-weight=bold; color=red;}


Fragment of the XSL-document, allowing to use similar style definitions:



<style-rule>

<target-element type = "issue"/>

<apply color = "blue"/>

</style-rule>

<style-rule>

<target-element type = "issue">

<attribute name = "class" value = "new"/>

</target-element>

<apply color = "red"/>

</style-rule>

<rule>

<target-element type = "issue"/>

<div>

<children/>

</div>

</rule>