Bump version to 4.1-6
[LibreOffice.git] / writerfilter / source / ooxml / analyzemodel.xsl
blob63ad7726ff17e414bc2b558c8ec486d902ff74fa
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 -->
20 <xsl:stylesheet version="1.0"
21 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
22 xmlns:rng="http://relaxng.org/ns/structure/1.0">
24 <xsl:include href="factorytools.xsl"/>
25 <xsl:output method="xml"/>
27 <xsl:template match="/">
28 <analyze>
29 <xsl:for-each select="/model/namespace[not(@todo='ignore')]">
30 <xsl:call-template name="analyzegrammar"/>
31 </xsl:for-each>
32 </analyze>
33 </xsl:template>
35 <xsl:template name="analyzegrammar">
36 <xsl:variable name="nsname" select="@name"/>
37 <xsl:for-each select="rng:grammar/rng:define">
38 <xsl:variable name="defname" select="@name"/>
39 <xsl:for-each select=".//rng:attribute|.//rng:element">
40 <xsl:choose>
41 <xsl:when test="local-name()='element'">
42 <element>
43 <xsl:call-template name="defineattrs">
44 <xsl:with-param name="nsname" select="$nsname"/>
45 <xsl:with-param name="defname" select="$defname"/>
46 </xsl:call-template>
47 </element>
48 </xsl:when>
49 <xsl:when test="local-name()='attribute'">
50 <attribute>
51 <xsl:call-template name="defineattrs">
52 <xsl:with-param name="nsname" select="$nsname"/>
53 <xsl:with-param name="defname" select="$defname"/>
54 </xsl:call-template>
55 </attribute>
56 </xsl:when>
57 </xsl:choose>
58 </xsl:for-each>
59 </xsl:for-each>
60 </xsl:template>
62 <xsl:template name="defineattrs">
63 <xsl:param name="nsname"/>
64 <xsl:param name="defname"/>
66 <xsl:variable name="localname" select="local-name()"/>
67 <xsl:variable name="name" select="@name"/>
69 <xsl:attribute name="id">
70 <xsl:value-of select="$nsname"/>
71 <xsl:text>:</xsl:text>
72 <xsl:value-of select="$defname"/>
73 <xsl:text>:</xsl:text>
74 <xsl:value-of select="@name"/>
75 </xsl:attribute>
76 <xsl:for-each select="ancestor::namespace/resource[@name=$defname]">
77 <xsl:attribute name="resource"><xsl:value-of select="@resource"/></xsl:attribute>
78 <xsl:choose>
79 <xsl:when test="$localname='attribute'">
80 <xsl:for-each select="attribute[@name=$name and @tokenid]">
81 <xsl:attribute name="tokenid"><xsl:value-of select="@tokenid"/></xsl:attribute>
82 <xsl:attribute name="qname">
83 <xsl:call-template name="idtoqname">
84 <xsl:with-param name="id" select="@tokenid"/>
85 </xsl:call-template>
86 </xsl:attribute>
87 <xsl:attribute name="namespace">
88 <xsl:value-of select="$nsname"/>
89 </xsl:attribute>
90 <xsl:attribute name="define">
91 <xsl:value-of select="$defname"/>
92 </xsl:attribute>
93 <xsl:attribute name="name">
94 <xsl:value-of select="@name"/>
95 </xsl:attribute>
96 </xsl:for-each>
97 </xsl:when>
98 <xsl:when test="$localname='element'">
99 <xsl:for-each select="element[@name=$name and @tokenid]">
100 <xsl:attribute name="tokenid"><xsl:value-of select="@tokenid"/></xsl:attribute>
101 <xsl:attribute name="qname">
102 <xsl:call-template name="idtoqname">
103 <xsl:with-param name="id" select="@tokenid"/>
104 </xsl:call-template>
105 </xsl:attribute>
106 <xsl:attribute name="namespace">
107 <xsl:value-of select="$nsname"/>
108 </xsl:attribute>
109 <xsl:attribute name="define">
110 <xsl:value-of select="$defname"/>
111 </xsl:attribute>
112 <xsl:attribute name="name">
113 <xsl:value-of select="@name"/>
114 </xsl:attribute>
115 </xsl:for-each>
116 </xsl:when>
117 </xsl:choose>
118 <xsl:copy-of select="@tag"/>
119 </xsl:for-each>
120 </xsl:template>
121 </xsl:stylesheet>