Deep XSL (5)---Union style sheet (turn)

Source: Internet
Author: User
Tags define contains include processing instruction relative xmlns xsl xsl stylesheet
Style sheet Depth xsl (5)
---Union style sheet
Translation: Sun Yizhong

XSL provides two mechanisms for federated style sheets:

1. style sheet import, allowing the style sheet to be referenced to each other
2. Style sheet contains, allows the style sheet to be combined with the original text.

Style sheet Import
An XSL style sheet can contain xsl:import elements. All xsl:import elements must appear at the beginning of the style sheet. The Xsl:import element has an HREF attribute whose value represents the URI of the style sheet to import. A relative URI is a base URI relative to the Xsl:import element.

<xsl:stylesheet xmlns:xsl= "Http://www.w3.org/TR/WD-xsl" >
<xsl:import href= "article.xsl"/>
<xsl:import href= "bigfont.xsl"/>
<xsl:define-attribute-set name= "Note-style" >
<xsl:attribute-set font-posture= "Italic"/>
</xsl:define-attribute-set>
</xsl:stylesheet>

The rules and definitions in the guided style sheet are more important than the rules and definitions in any of the imported style sheets. Similarly, the rules and definitions in an imported style sheet are more important than the rules and definitions in the style sheet that you imported earlier. In general, More important rules or definitions take precedence over important rules or definitions. The rules and definitions in each category will be specified in detail.

The style sheet contains
You can use the Xsl:include element in one style sheet to contain another XSL style sheet. Xsl:include also has the href attribute, whose value represents the URI of the included style sheet. A relative URI is a base URI relative to the xsl:include element. The Xsl:include element can be a child element of a xsl:stylesheet element, appearing after any xsl:import. The hierarchy of the XML tree should be in effect on the. The resource content positioned by the href attribute value is parsed as an XML document in which the xsl: The stylesheet element replaces the Xsl:include element that contains the document. Also after the Xsl:import element of the contained document is moved up to any existing xsl:import element in the containing document. Unlike Xsl:import, the contained rules or definitions do not affect the way in which they are processed.

Embed style sheet
Typically, a stylesheet is a complete XML document that Xsl:stylesheet elements as elements of a document. However, an XSL stylesheet can also be embedded in other document content. There may be two ways in which an XSL stylesheet can be embedded in a non-XML document or xsl: Stylesheet does not appear as a document element in an XML document. In the second case, there is a possibility that the inline style, which is the document of its own style, is added. XSL has not yet defined a mechanism for it. This is accomplished by using a common way of combining stylesheets with documents, as long as you meet

1. This method allows part of the content to be defined as a style sheet, such as using a fragment identifier URI
2. The method itself can be embedded in the document, such as as a processing instruction. Defining such a way is not within the scope of the XSL.

The following example shows how to combine style sheets and documents with xml:stylesheet processing instructions to implement inline styles. The URI uses a xpointer in the fragment identifier to determine the position of the xsl:stylesheet element.

<?xml version= "1.0"?>
<?xml:stylesheet type= "text/xsl" href= "#id (style1)"?>
<! DOCTYPE doc SYSTEM "DOC.DTD" >
<doc>
<xsl:stylesheet xmlns:xsl= "http://www.w3.org/TR/WD-xsl" id= "Style1" >
<xsl:import href= "doc.xsl"/>
<xsl:template match= "ID (foo)" >
<fo:block font-weight= "Bold" ><xsl:process-children/></fo:block>
</xsl:template>
</xsl:stylesheet>
<body>

<para id= "foo" >
...
</para>

</body>
</doc>


----------------------------------------------------------------------------


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.