1cdf0e10cSrcweir<?xml version='1.0' encoding="UTF-8"?> 2*1e519d8dSAndrew Rist<!--*********************************************************** 3*1e519d8dSAndrew Rist * 4*1e519d8dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 5*1e519d8dSAndrew Rist * or more contributor license agreements. See the NOTICE file 6*1e519d8dSAndrew Rist * distributed with this work for additional information 7*1e519d8dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 8*1e519d8dSAndrew Rist * to you under the Apache License, Version 2.0 (the 9*1e519d8dSAndrew Rist * "License"); you may not use this file except in compliance 10*1e519d8dSAndrew Rist * with the License. You may obtain a copy of the License at 11*1e519d8dSAndrew Rist * 12*1e519d8dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 13*1e519d8dSAndrew Rist * 14*1e519d8dSAndrew Rist * Unless required by applicable law or agreed to in writing, 15*1e519d8dSAndrew Rist * software distributed under the License is distributed on an 16*1e519d8dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17*1e519d8dSAndrew Rist * KIND, either express or implied. See the License for the 18*1e519d8dSAndrew Rist * specific language governing permissions and limitations 19*1e519d8dSAndrew Rist * under the License. 20*1e519d8dSAndrew Rist * 21*1e519d8dSAndrew Rist ***********************************************************--> 22cdf0e10cSrcweir 23cdf0e10cSrcweir 24cdf0e10cSrcweir<xsl:stylesheet version="1.0" 25cdf0e10cSrcweir xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 26cdf0e10cSrcweir xmlns:redirect="http://xml.apache.org/xalan/redirect" 27cdf0e10cSrcweir extension-element-prefixes="redirect"> 28cdf0e10cSrcweir<xsl:output method="text" indent="no" omit-xml-declaration="no" version="1.0" encoding="UTF-8" /> 29cdf0e10cSrcweir 30cdf0e10cSrcweir <!-- OPTIONAL: output directory for the IDL 31cdf0e10cSrcweir Have to end with path separator --> 32cdf0e10cSrcweir <xsl:param name="IDL_DIRECTORY" /> 33cdf0e10cSrcweir 34cdf0e10cSrcweir <xsl:key name="same-context-elements" 35cdf0e10cSrcweir match="/api/element[@type='constant']" 36cdf0e10cSrcweir use="normalize-space(source/context)" /> 37cdf0e10cSrcweir 38cdf0e10cSrcweir <xsl:template match="/"> 39cdf0e10cSrcweir <!-- once for each enumeration --> 40cdf0e10cSrcweir <xsl:for-each select="/api/element[@type='enumeration']"> 41cdf0e10cSrcweir <xsl:sort select="normalize-space(source/name)" /> 42cdf0e10cSrcweir 43cdf0e10cSrcweir <redirect:write select="concat($IDL_DIRECTORY, normalize-space(source/name),'.idl')"> 44cdf0e10cSrcweir <xsl:call-template name="write-idl-prefix-1" /> 45cdf0e10cSrcweir <xsl:call-template name="write-idl-prefix-2" /> 46cdf0e10cSrcweir <!-- write IDL content --> 47cdf0e10cSrcweir <xsl:for-each select="key('same-context-elements', normalize-space(source/name))"> 48cdf0e10cSrcweir <xsl:call-template name="write-idl-content" /> 49cdf0e10cSrcweir </xsl:for-each> 50cdf0e10cSrcweir <xsl:call-template name="write-idl-suffix" /> 51cdf0e10cSrcweir </redirect:write> 52cdf0e10cSrcweir </xsl:for-each> 53cdf0e10cSrcweir </xsl:template> 54cdf0e10cSrcweir 55cdf0e10cSrcweir 56cdf0e10cSrcweir <!-- writing the IDL prefix --> 57cdf0e10cSrcweir <xsl:template name="write-idl-prefix-1"> 58cdf0e10cSrcweir <xsl:variable name="submod" select="source/@id"/> 59cdf0e10cSrcweir <xsl:variable name="period" select="'.'"/> 60cdf0e10cSrcweir <xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable> 61cdf0e10cSrcweir <xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable> 62cdf0e10cSrcweir<xsl:text> 63cdf0e10cSrcweir module org { module openoffice { module </xsl:text><xsl:value-of select="translate(substring-before($submod,$period),$ucletters,$lcletters)"/> 64cdf0e10cSrcweir </xsl:template> 65cdf0e10cSrcweir <xsl:template name="write-idl-prefix-2"> 66cdf0e10cSrcweir<xsl:text> { 67cdf0e10cSrcweir constants </xsl:text><xsl:value-of select="normalize-space(source/name)" /><xsl:text> {</xsl:text> 68cdf0e10cSrcweir </xsl:template> 69cdf0e10cSrcweir 70cdf0e10cSrcweir <!-- writing the IDL content --> 71cdf0e10cSrcweir <xsl:template name="write-idl-content"> 72cdf0e10cSrcweir<xsl:text> 73cdf0e10cSrcweir const long </xsl:text><xsl:value-of select="source/name" /><xsl:text> = </xsl:text><xsl:value-of select="source/value" /><xsl:text>;</xsl:text> 74cdf0e10cSrcweir </xsl:template> 75cdf0e10cSrcweir 76cdf0e10cSrcweir <!-- writing the IDL suffix --> 77cdf0e10cSrcweir <xsl:template name="write-idl-suffix"> 78cdf0e10cSrcweir<xsl:text> 79cdf0e10cSrcweir }; 80cdf0e10cSrcweir }; }; }; 81cdf0e10cSrcweir</xsl:text> 82cdf0e10cSrcweir </xsl:template> 83cdf0e10cSrcweir</xsl:stylesheet> 84cdf0e10cSrcweir 85