Project

Profile

Help

How to connect?
Download (3.08 KB) Statistics
| Branch: | Revision:

he / tools / doc-include.xsl @ 5d25f10d

1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
  xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs doc cat"
4
  xmlns:doc="http://www.saxonica.com/ns/doc" xmlns:cat="http://www.saxonica.com/ns/doc/catalog"
5
  version="3.0">
6
  <doc:doc>
7
    <p>This simple stylesheet processes embedded xinclude directives in the documentation. Its
8
      principal input is the catalog.xml file within
9
      userdoc/saxon9/src.<!-- For any
10
        <code>cat:section</code> entry that has <code>@include='yes'</code>, it is assumed that the
11
      master file, which may contain inclusions, is contained at <code>{@ref}/{@ref}.xml</code> - it
12
      will be include-processed to generate <code>{@ref}.xml</code> as a sibling of the catalog
13
      file. --></p>
14
    <p>It requires execution with the -xi:on option to handle inclusions.</p>
15
    <p>Modified 2018-09-21: to also remove comment nodes.</p>
16
  </doc:doc>
17

    
18
  <!--<xsl:param name="output" as="xs:string?"
19
    doc:doc="Possible output URI for use in Ant, which will be resolved relative to base-URI"
20
    >../viewer_app/doc/catalog.xml</xsl:param>-->
21
  
22
  <xsl:param name="output-uri" select="''"/>  
23

    
24
  <xsl:output method="xml" indent="yes"/>
25
  <xsl:variable name="base-uri" select="base-uri(/)"/>
26

    
27
  <xsl:mode on-no-match="shallow-copy"/>
28
  <xsl:template match="/">
29
    <xsl:apply-templates select=".//cat:section" mode="include"/>
30
    <xsl:next-match/>
31
  </xsl:template>
32
  <xsl:template match="cat:catalog">
33
    <xsl:copy>
34
      <xsl:apply-templates select="@*" mode="#current"/>
35
      <xsl:comment>Processed:
36
        <xsl:value-of use-when="true()" select="format-dateTime(current-dateTime(),'[Y] [MNn] [D01] @ [H01]:[m]')"/>
37
        <xsl:value-of use-when="false()" select="current-dateTime()"/>
38
      </xsl:comment>
39
      <xsl:apply-templates select="*" mode="#current"/>
40
    </xsl:copy>
41
  </xsl:template>
42

    
43
  <xsl:template match="cat:section" mode="include">
44
    <!--<xsl:variable name="dir" select="if(@include='yes') then (@ref,'/') else ()"/>
45
    <xsl:variable name="src" select="resolve-uri(string-join(($dir,@ref,'.xml')),$base-uri)"/>-->
46
    <xsl:variable name="name" select="string-join((@ref,'.xml'))"/>
47
    <xsl:variable name="src" select="resolve-uri($name,$base-uri)"/>
48
    <xsl:choose>
49
      <xsl:when test="doc-available(xs:string($src))">
50
      <!--<xsl:variable name="href"
51
        select="if(exists($output))
52
            then resolve-uri($name,resolve-uri($output,$base-uri)) 
53
            else $name"/>
54
      <xsl:result-document href="{$href}">-->      
55
      <xsl:result-document href="{$output-uri}/{$name}">
56
        <xsl:apply-templates select="document($src)"/>
57
      </xsl:result-document>
58
      </xsl:when>
59
      <xsl:otherwise>
60
        <xsl:message select="'Failed to load: …/build/' || substring-after($src, '/build/')"/>
61
      </xsl:otherwise>
62
    </xsl:choose>
63
  </xsl:template>
64

    
65
  <xsl:template match="xi:include" xmlns:xi="http://www.w3.org/2001/XInclude">
66
    <xsl:message>WHAT THE HECK? <xsl:value-of select="@href"/></xsl:message>
67
  </xsl:template>
68
  
69
  <xsl:template match="comment()"/>
70

    
71
</xsl:stylesheet>
(6-6/15)