GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
1
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
nigel.stanger
/
XML
Browse code
- Made use of newline-internal template.
master
1 parent
6015fe7
commit
6a78bd88e2f6bb0379e851b2bbe1578bf6ed747a
nstanger
authored
on 7 Oct 2011
Patch
Showing
2 changed files
modules/inclusions.xml
modules/latex.xml
Ignore Space
Show notes
View
modules/inclusions.xml
<?xml version="1.0" encoding="utf-8"?> <!-- Including other XML/HTML/LaTeX documents into the current one. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Include another XML/HTML/LaTeX document into the current one. If you don't specify @type, it assumes the type of document that you're currently generating (HTML or LaTeX). LaTeX documents are simply included using \input{...}. HTML documents are a little trickier, as there's no equivalent of \input{} in HTML, plus the XSLT processor always seems to generate a DOCTYPE when producing HTML, whether you want it or not, which means that you can only really include entire HTML documents, rather than HTML fragments (maybe you can turn this off?). The workaround currently is to embed the HTML document inside an <object>. A similar argument applies for plain text documents (such as code listings) that we want to include, but are externally generated and so can't just be embedded in the source XML. @type: The type of the document to be included. [optional] Valid values are: "xml" "html" [default for HTML] "latex" [default for LaTeX] "plain" (as in text/plain) @basename: Name of file to include (including suffix!). [required] @location: Path to file to include. Note that this gets a / appended to it. However, this shouldn't make any difference in normal usage. [optional] --> <template name="include-document" match="include-document"> <common> <!-- Work out the full path specification for the file to be included = base-path + location + basename. --> <xsl:variable name="file"> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <xsl:value-of select="@basename" /> </xsl:variable> </common> <common formats="/html/xhtml/"> <div> <xsl:attribute name="align"> <xsl:choose> <xsl:when test="@align"><xsl:value-of select="@align" /></xsl:when> <xsl:otherwise>left</xsl:otherwise> </xsl:choose> </xsl:attribute> <object data="{$file}"> <!-- Output text/html or text/plain as appropriate. --> <xsl:attribute name="type"> <xsl:text>text/</xsl:text> <xsl:choose> <xsl:when test="@type"><xsl:value-of select="@type" /></xsl:when> <xsl:otherwise><xsl:text>html</xsl:text></xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="width"> <xsl:choose> <xsl:when test="@width"><xsl:value-of select="@width" /></xsl:when> <xsl:otherwise><xsl:text>100%</xsl:text></xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="height"> <xsl:choose> <xsl:when test="@height"><xsl:value-of select="@height" /></xsl:when> <xsl:otherwise><xsl:text>100%</xsl:text></xsl:otherwise> </xsl:choose> </xsl:attribute> </object> </div> </common> <common formats="/latex/xelatex/"> <xsl:text>\</xsl:text> <!-- Note that input text files are currently verbatim'd in LaTeX. We may want to change this in future? --> <xsl:if test="@type = 'plain'"> <xsl:text>verbatim</xsl:text> </xsl:if> <xsl:text>input{</xsl:text> <xsl:value-of select="$file" /> <xsl:text>}</xsl:text> <xsl:call-template name="newline-internal" /> </common> </template> <!-- Note that including XML documents is currently problematic, as the document() function expects a valid XML document. Including XML fragments is impossible. XInclude will fix this, once it is widely supported (not yet). Best to avoid this completely for now. --> <template name="include-xml" match="include-document[@type='xml']"> <common> <xsl:variable name="file"> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <xsl:value-of select="@basename" /> </xsl:variable> <xsl:apply-templates select="document($file,/)" /> </common> </template> </stylesheet>
<?xml version="1.0" encoding="utf-8"?> <!-- Including other XML/HTML/LaTeX documents into the current one. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Include another XML/HTML/LaTeX document into the current one. If you don't specify @type, it assumes the type of document that you're currently generating (HTML or LaTeX). LaTeX documents are simply included using \input{...}. HTML documents are a little trickier, as there's no equivalent of \input{} in HTML, plus the XSLT processor always seems to generate a DOCTYPE when producing HTML, whether you want it or not, which means that you can only really include entire HTML documents, rather than HTML fragments (maybe you can turn this off?). The workaround currently is to embed the HTML document inside an <object>. A similar argument applies for plain text documents (such as code listings) that we want to include, but are externally generated and so can't just be embedded in the source XML. @type: The type of the document to be included. [optional] Valid values are: "xml" "html" [default for HTML] "latex" [default for LaTeX] "plain" (as in text/plain) @basename: Name of file to include (including suffix!). [required] @location: Path to file to include. Note that this gets a / appended to it. However, this shouldn't make any difference in normal usage. [optional] --> <template name="include-document" match="include-document"> <common> <!-- Work out the full path specification for the file to be included = base-path + location + basename. --> <xsl:variable name="file"> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <xsl:value-of select="@basename" /> </xsl:variable> </common> <common formats="/html/xhtml/"> <div> <xsl:attribute name="align"> <xsl:choose> <xsl:when test="@align"><xsl:value-of select="@align" /></xsl:when> <xsl:otherwise>left</xsl:otherwise> </xsl:choose> </xsl:attribute> <object data="{$file}"> <!-- Output text/html or text/plain as appropriate. --> <xsl:attribute name="type"> <xsl:text>text/</xsl:text> <xsl:choose> <xsl:when test="@type"><xsl:value-of select="@type" /></xsl:when> <xsl:otherwise><xsl:text>html</xsl:text></xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="width"> <xsl:choose> <xsl:when test="@width"><xsl:value-of select="@width" /></xsl:when> <xsl:otherwise><xsl:text>100%</xsl:text></xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="height"> <xsl:choose> <xsl:when test="@height"><xsl:value-of select="@height" /></xsl:when> <xsl:otherwise><xsl:text>100%</xsl:text></xsl:otherwise> </xsl:choose> </xsl:attribute> </object> </div> </common> <common formats="/latex/xelatex/"> <xsl:text>\</xsl:text> <!-- Note that input text files are currently verbatim'd in LaTeX. We may want to change this in future? --> <xsl:if test="@type = 'plain'"> <xsl:text>verbatim</xsl:text> </xsl:if> <xsl:text>input{</xsl:text> <xsl:value-of select="$file" /> <xsl:text>}</xsl:text> </common> </template> <!-- Note that including XML documents is currently problematic, as the document() function expects a valid XML document. Including XML fragments is impossible. XInclude will fix this, once it is widely supported (not yet). Best to avoid this completely for now. --> <template name="include-xml" match="include-document[@type='xml']"> <common> <xsl:variable name="file"> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <xsl:value-of select="@basename" /> </xsl:variable> <xsl:apply-templates select="document($file,/)" /> </common> </template> </stylesheet>
Ignore Space
Show notes
View
modules/latex.xml
<?xml version="1.0" encoding="utf-8"?> <!-- LaTeX-specific items. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Environment setup. This enables you to define environment settings (e.g., required LaTeX packages, etc.). We normally explicitly call the sub-elements within this, so this template is empty to prevent unwanted stuff accidentally being included in the output. --> <template name="environment" match="environment" /> <!-- Load a LaTeX package. @options: Any arguments to the package. [optional] --> <template name="latex-package" match="latex-packages/package"> <common formats="/latex/xelatex/"> <xsl:text>\usepackage</xsl:text> <xsl:if test="@options"> <xsl:text>[</xsl:text> <xsl:value-of select="@options" /> <xsl:text>]</xsl:text> </xsl:if> <xsl:text>{</xsl:text> <xsl:value-of select="." /> <xsl:text>}</xsl:text> <xsl:call-template name="newline-internal" /> </common> </template> <!-- Execute a preamble LaTeX command. Use to set up things like counters, fonts, hyperref options, etc. --> <template name="latex-command" match="latex-commands/command"> <common formats="/latex/xelatex/"> <xsl:value-of select="." /> <xsl:call-template name="newline-internal" /> </common> </template> <!-- LaTeX hyphenation. A space-delimited list of hyphenated words. --> <template name="latex-hyphenation" match="latex-commands/hyphenation"> <common formats="/latex/xelatex/"> <xsl:text>\hyphenation{</xsl:text> <xsl:value-of select="." /> <xsl:text>}</xsl:text> <xsl:call-template name="newline-internal" /> </common> </template> <!-- Specify LaTeX document class and options. The master stylesheet specifies \documentclass[a4paper,12pt]{article}. Anything you specify here will override that completely, so be sure to set a4paper and 12pt if that's what you want. @options: The required document class options. [optional] --> <!-- Hmm, this may be more complex than I thought... External environment files sort of stuff it up. Perhaps LaTeX document class stuff should be in attributes of the document element? --> <template name="latex-documentclass" match="latex-documentclass|documentclass"> <common formats="/latex/xelatex/"> <xsl:text>\documentclass[</xsl:text> <xsl:value-of select="@options" /> <xsl:text>]{</xsl:text> <xsl:value-of select="." /> <xsl:text>}</xsl:text> <xsl:call-template name="newline-internal" /> </common> </template> <!-- Durr, this is identical to the previous one??? --> <template name="latex-documentclass-options" match="latex-documentclass[@options]|documentclass[@options]"> <common formats="/latex/xelatex/"> <xsl:text>\documentclass[</xsl:text> <xsl:value-of select="@options" /> <xsl:text>]{</xsl:text> <xsl:value-of select="." /> <xsl:text>}</xsl:text> <xsl:call-template name="newline-internal" /> </common> </template> <!-- Specify additional LaTeX document class options (i.e., in addition to the defaults). These should be a comma-separated list of the required options. These will be appended to the standard defaults (a4paper, 12pt). --> <template name="latex-document-options" match="latex-document-options"> <common formats="/latex/xelatex/"> <xsl:apply-templates /> </common> </template> </stylesheet>
<?xml version="1.0" encoding="utf-8"?> <!-- LaTeX-specific items. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Environment setup. This enables you to define environment settings (e.g., required LaTeX packages, etc.). We normally explicitly call the sub-elements within this, so this template is empty to prevent unwanted stuff accidentally being included in the output. --> <template name="environment" match="environment" /> <!-- Load a LaTeX package. @options: Any arguments to the package. [optional] --> <template name="latex-package" match="latex-packages/package"> <common formats="/latex/xelatex/"> <xsl:text>\usepackage</xsl:text> <xsl:if test="@options"> <xsl:text>[</xsl:text> <xsl:value-of select="@options" /> <xsl:text>]</xsl:text> </xsl:if> <xsl:text>{</xsl:text> <xsl:value-of select="." /> <xsl:text>}</xsl:text> </common> </template> <!-- Execute a preamble LaTeX command. Use to set up things like counters, fonts, hyperref options, etc. --> <template name="latex-command" match="latex-commands/command"> <common formats="/latex/xelatex/"><xsl:value-of select="." /></common> </template> <!-- LaTeX hyphenation. A space-delimited list of hyphenated words. --> <template name="latex-hyphenation" match="latex-commands/hyphenation"> <common formats="/latex/xelatex/"> <xsl:text>\hyphenation{</xsl:text> <xsl:value-of select="." /> <xsl:text>}</xsl:text> </common> </template> <!-- Specify LaTeX document class and options. The master stylesheet specifies \documentclass[a4paper,12pt]{article}. Anything you specify here will override that completely, so be sure to set a4paper and 12pt if that's what you want. @options: The required document class options. [optional] --> <!-- Hmm, this may be more complex than I thought... External environment files sort of stuff it up. Perhaps LaTeX document class stuff should be in attributes of the document element? --> <template name="latex-documentclass" match="latex-documentclass|documentclass"> <common formats="/latex/xelatex/"> <xsl:text>\documentclass[</xsl:text> <xsl:value-of select="@options" /> <xsl:text>]{</xsl:text> <xsl:value-of select="." /> <xsl:text>}</xsl:text> </common> </template> <!-- Durr, this is identical to the previous one??? --> <template name="latex-documentclass-options" match="latex-documentclass[@options]|documentclass[@options]"> <common formats="/latex/xelatex/"> <xsl:text>\documentclass[</xsl:text> <xsl:value-of select="@options" /> <xsl:text>]{</xsl:text> <xsl:value-of select="." /> <xsl:text>}</xsl:text> </common> </template> <!-- Specify additional LaTeX document class options (i.e., in addition to the defaults). These should be a comma-separated list of the required options. These will be appended to the standard defaults (a4paper, 12pt). --> <template name="latex-document-options" match="latex-document-options"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> </template> </stylesheet>
Show line notes below