1<!--***********************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 ***********************************************************-->
21
22
23<xsl:stylesheet
24    version="1.0"
25    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
26    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
27    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
28    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
29    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
30    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
31    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
32    xmlns:xlink="http://www.w3.org/1999/xlink"
33    xmlns:dc="http://purl.org/dc/elements/1.1/"
34    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
35    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
36    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
37    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
38    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
39    xmlns:math="http://www.w3.org/1998/Math/MathML"
40    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
41    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
42    xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
43    xmlns:ooo="http://openoffice.org/2004/office"
44    xmlns:ooow="http://openoffice.org/2004/writer"
45    xmlns:oooc="http://openoffice.org/2004/calc"
46    xmlns:dom="http://www.w3.org/2001/xml-events"
47    xmlns:xforms="http://www.w3.org/2002/xforms"
48    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
49    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
50    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
51    xmlns:rng="http://relaxng.org/ns/structure/1.0"
52    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
53    xmlns:xalan="http://xml.apache.org/xalan"
54    xmlns:UML = 'org.omg.xmi.namespace.UML'
55    exclude-result-prefixes = "xalan"
56    xml:space="default">
57  <xsl:output method="text" />
58
59  <xsl:include href="factorytools.xsl"/>
60
61  <!--
62      Generates mapping from tokenids to strings. (DEBUG)
63  -->
64  <xsl:template name="qnametostr">
65    <xsl:text>
66void QNameToString::init_ooxml()
67{
68    /* ooxml */
69    </xsl:text>
70    <xsl:for-each select="//@tokenid">
71      <xsl:if test="generate-id(.) = generate-id(key('tokenids', .)[1]) and contains(., 'ooxml:')">
72        <xsl:text>
73    mMap[</xsl:text>
74    <xsl:call-template name="idtoqname">
75      <xsl:with-param name="id" select="."/>
76    </xsl:call-template>
77    <xsl:text>] = "</xsl:text>
78    <xsl:value-of select="."/>
79    <xsl:text>";</xsl:text>
80      </xsl:if>
81    </xsl:for-each>
82    <xsl:text>
83}
84    </xsl:text>
85  </xsl:template>
86
87  <xsl:template name="ooxmlidstoxml">
88    <xsl:text>
89void ooxmlsprmidsToXML(::std::ostream &amp; out)
90{</xsl:text>
91    <xsl:for-each select="//@tokenid">
92      <xsl:if test="contains(., 'ooxml:') and generate-id(.) = generate-id(key('tokenids', .)[1]) and ancestor::element">
93        <xsl:text>
94    out &lt;&lt; "&lt;theid name=\"</xsl:text>
95    <xsl:value-of select="."/>
96    <xsl:text>\"&gt;</xsl:text>
97    <xsl:value-of select="90000 + position()"/>
98    <xsl:text>&lt;/theid&gt;" &lt;&lt; endl; </xsl:text>
99      </xsl:if>
100    </xsl:for-each>
101    <xsl:text>
102}</xsl:text>
103    <xsl:text>
104void ooxmlidsToXML(::std::ostream &amp; out)
105{</xsl:text>
106    <xsl:for-each select="//@tokenid">
107      <xsl:if test="contains(., 'ooxml:') and generate-id(.) = generate-id(key('tokenids', .)[1]) and ancestor::attribute">
108        <xsl:text>
109    out &lt;&lt; "&lt;theid name=\"</xsl:text>
110    <xsl:value-of select="."/>
111    <xsl:text>\"&gt;</xsl:text>
112    <xsl:value-of select="90000 + position()"/>
113    <xsl:text>&lt;/theid&gt;" &lt;&lt; endl; </xsl:text>
114      </xsl:if>
115    </xsl:for-each>
116    <xsl:text>
117}</xsl:text>
118  </xsl:template>
119
120  <xsl:template match="/">
121    <xsl:call-template name="qnametostr"/>
122    <xsl:call-template name="ooxmlidstoxml"/>
123  </xsl:template>
124
125</xsl:stylesheet>