1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
<?xml version="1.0"?>
<!DOCTYPE SSource SYSTEM "/home/duncan/Projects/org/omegahat/XML/RS/examples/SSource.dtd"
[
<!ENTITY lt "<" >
<!-- Temporarily use _ rather thant <- as it screws things up. -->
<!ENTITY sgets "<-" >
<!ENTITY Latex "LaTex" >
]>
<!--
We can define sgets here and avoid validation
forced by reading the DTD to get these entities.
[ <!ENTITY sgets "<-">
]>
-->
<SSource>
<overview>
The functions in this file are an initial attempt to define some
filters for an XML document to produce &Latex; output by translating
the contents of the XML document.
Note that using XSL is slightly problematic because the result needs
to be a valid XML document, which no &Latex; document ever is.
</overview>
<function lang="S">
<sname>xml2tex</sname>
<def>
function(node, mappings=.XMLTexMappings) {
n &sgets; 10
x &sgets; <fragmentRef id="frag1" />
print(x+10)
x
}
</def>
</function>
<expression>
cat("Got to here\n")
</expression>
<?R cat("A processing instruction\n") ?>
<function>
<sname>xml2texUnderline</sname>
<def>
function(node, tex)
{
}
</def>
</function>
<function>
<def>
xml2texCode &sgets;
function(node, tex)
{
}
</def>
</function>
<function lang="SPlus">
<sname>xxx</sname>
<def>
<![CDATA[
x &sgets; 1
]]>
</def>
</function>
<fragment id="frag1">
seq(1,n)
<fragmentRef id="frag2" />
</fragment>
<fragment id="frag2">
+ 10
</fragment>
<Sexpression>
xml2tex.map &sgets;
list("i"="textit",
"b"="textbf",
"sfunction"="SFunction",
"item"="item",
"label"=c("[", "]"),
"cite"=function(x) { paste("\cite{", xmlAttrs(x)["id"], "}", collapse="")},
"bibitem"="",
"bibliography"=""
)
</Sexpression>
<function>
<sname>mapXML2TeX</sname>
<def>
function(node, attr) {
name &sgets; xmlName(node)
el &sgets; xml2tex.map[[name]]
if(!is.null(el)) {
if(mode(el) == "character") {
} else if(mode(el) == "function") {
el(node)
}
}
}
</def>
</function>
</SSource>
|