Bump version to 4.1-6
[LibreOffice.git] / writerfilter / source / resourcemodel / namespace_preprocess.pl
blob5897a8d471beae87866cf1938419e47907d49498
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 $ARGV0 = shift @ARGV;
21 print <<EOF;
22 <?xml version="1.0"?>
23 <xsl:stylesheet version="1.0"
24 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
25 <xsl:output method="xml"/>
27 <xsl:include href="./modelpreprocess.xsl"/>
29 <xsl:template match="namespace-alias[\@id]">
30 <xsl:variable name="value">
31 <xsl:call-template name="getnamespaceid">
32 <xsl:with-param name="id" select="\@id" />
33 </xsl:call-template>
34 </xsl:variable>
35 <xsl:copy>
36 <xsl:apply-templates select="@*"/>
37 <xsl:attribute name="id">
38 <xsl:value-of select="\$value"/>
39 </xsl:attribute>
40 </xsl:copy>
41 </xsl:template>
43 <xsl:template name="getnamespaceid">
44 <xsl:param name='id'/>
45 <xsl:choose>
46 EOF
49 # print the mapping
50 open ( NAMESPACES, $ARGV0 ) || die "can't open namespace file: $!";
51 while ( <NAMESPACES> )
53 chomp( $_ );
54 # line format is: numeric-id short-name namespace-URL
55 $_ =~ /^([0-9]+)\s+([a-zA-Z]+)\s+([a-zA-Z0-9-.:\/]+)\s*$/ or die "Error: invalid character in input data";
56 print <<EOF;
57 <xsl:when test="\$id = '$2'">
58 <xsl:text>$1</xsl:text>
59 </xsl:when>
60 EOF
63 print <<EOF;
64 </xsl:choose>
65 </xsl:template>
67 </xsl:stylesheet>
68 EOF