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$ARGV0 = shift @ARGV; 22 23print <<EOF; 24<?xml version="1.0"?> 25<xsl:stylesheet version="1.0" 26 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 27 <xsl:output method="xml"/> 28 29 <xsl:include href="./modelpreprocess.xsl"/> 30 31 <xsl:template match="namespace-alias[\@id]"> 32 <xsl:variable name="value"> 33 <xsl:call-template name="getnamespaceid"> 34 <xsl:with-param name="id" select="\@id" /> 35 </xsl:call-template> 36 </xsl:variable> 37 <xsl:copy> 38 <xsl:apply-templates select="@*"/> 39 <xsl:attribute name="id"> 40 <xsl:value-of select="\$value"/> 41 </xsl:attribute> 42 </xsl:copy> 43 </xsl:template> 44 45 <xsl:template name="getnamespaceid"> 46 <xsl:param name='id'/> 47 <xsl:choose> 48EOF 49 50 51# print the mapping 52open ( NAMESPACES, $ARGV0 ) || die "can't open namespace file: $!"; 53while ( <NAMESPACES> ) 54{ 55 chomp( $_ ); 56 # line format is: numeric-id short-name namespace-URL 57 $_ =~ /^([0-9]+)\s+([a-zA-Z]+)\s+([a-zA-Z0-9-.:\/]+)\s*$/ or die "Error: invalid character in input data"; 58 print <<EOF; 59 <xsl:when test="\$id = '$2'"> 60 <xsl:text>$1</xsl:text> 61 </xsl:when> 62EOF 63} 64 65print <<EOF; 66 </xsl:choose> 67 </xsl:template> 68 69</xsl:stylesheet> 70EOF 71