/ libxml2 / win32 / defgen.xsl
defgen.xsl
  1  <?xml version="1.0"?>
  2  <!-- 
  3  	win32/defgen.xsl
  4  	This stylesheet is used to transform doc/libxml2-api.xml into a pseudo-source,
  5  	which can then be preprocessed to get the .DEF file for the Microsoft's linker.
  6  	
  7  	Use any XSLT processor to produce a file called libxml2.def.src in the win32
  8  	subdirectory, for example, run xsltproc from the win32 subdirectory:
  9  	
 10  	  xsltproc -o libxml2.def.src defgen.xsl ../doc/libxml2-api.xml
 11  	  
 12  	Once that finishes, rest assured, the Makefile will know what to do with the
 13  	generated file. 
 14  
 15  	April 2003, Igor Zlatkovic <igor@zlatkovic.com>
 16  -->
 17  <!DOCTYPE xsl:stylesheet [ <!ENTITY nl '&#xd;&#xa;'> ]>
 18  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 19  	<xsl:strip-space elements="*"/>
 20  	<xsl:output method="text"/>
 21  	<xsl:template match="/">
 22  		<xsl:text>#define LIBXML2_COMPILING_MSCCDEF&nl;</xsl:text>
 23  		<xsl:text>#include "../include/libxml/xmlversion.h"&nl;</xsl:text>
 24  		<xsl:text>LIBRARY libxml2&nl;</xsl:text>
 25  		<xsl:text>EXPORTS&nl;</xsl:text>
 26  		<xsl:for-each select="/api/symbols/*[self::variable or self::function]">
 27  			<!-- Basic tests -->
 28  			<xsl:if test="@file = 'c14n'">
 29  				<xsl:text>#ifdef LIBXML_C14N_ENABLED&nl;</xsl:text>
 30  			</xsl:if>
 31  			<xsl:if test="@file = 'catalog'">
 32  				<xsl:text>#ifdef LIBXML_CATALOG_ENABLED&nl;</xsl:text>
 33  			</xsl:if>
 34  			<xsl:if test="@file = 'debugXML'">
 35  				<xsl:text>#ifdef LIBXML_DEBUG_ENABLED&nl;</xsl:text>
 36  			</xsl:if>
 37  			<xsl:if test="@file = 'DOCBparser'">
 38  				<xsl:text>#ifdef LIBXML_DOCB_ENABLED&nl;</xsl:text>
 39  			</xsl:if>
 40  			<xsl:if test="(@file = 'HTMLparser') 
 41  					or (@file = 'HTMLtree')">
 42  				<xsl:text>#ifdef LIBXML_HTML_ENABLED&nl;</xsl:text>
 43  			</xsl:if>
 44  			<xsl:if test="@file = 'nanohttp'">
 45  				<xsl:text>#ifdef LIBXML_HTTP_ENABLED&nl;</xsl:text>
 46  			</xsl:if>
 47  			<xsl:if test="@file = 'nanoftp'">
 48  				<xsl:text>#ifdef LIBXML_FTP_ENABLED&nl;</xsl:text>
 49  			</xsl:if>
 50  			<xsl:if test="(@file = 'relaxng') 
 51  					or (@file = 'xmlschemas') 
 52  					or (@file = 'xmlschemastypes')">
 53  				<xsl:text>#ifdef LIBXML_SCHEMAS_ENABLED&nl;</xsl:text>
 54  			</xsl:if>
 55  			<xsl:if test="@file = 'xinclude'">
 56  				<xsl:text>#ifdef LIBXML_XINCLUDE_ENABLED&nl;</xsl:text>
 57  			</xsl:if>
 58  			<xsl:if test="@file = 'xlink'">
 59  				<xsl:text>#ifdef LIBXML_XLINK_ENABLED&nl;</xsl:text>
 60  			</xsl:if>
 61  			<xsl:if test="@file = 'xmlautomata'">
 62  				<xsl:text>#ifdef LIBXML_AUTOMATA_ENABLED&nl;</xsl:text>
 63  			</xsl:if>
 64  			<xsl:if test="(@file = 'xmlregexp') 
 65  					or (@file = 'xmlunicode')">
 66  				<xsl:text>#ifdef LIBXML_REGEXP_ENABLED&nl;</xsl:text>
 67  			</xsl:if>
 68  			<xsl:if test="(@file = 'xpath') 
 69  					or (@file = 'xpathInternals')">
 70  				<xsl:text>#ifdef LIBXML_XPATH_ENABLED&nl;</xsl:text>
 71  			</xsl:if>
 72  			<xsl:if test="@file = 'xpointer'">
 73  				<xsl:text>#ifdef LIBXML_XPTR_ENABLED&nl;</xsl:text>
 74  			</xsl:if>
 75  			<!-- Extended tests -->
 76  			<xsl:if test="(@name = 'htmlDefaultSAXHandlerInit') 
 77  					or (@name = 'htmlInitAutoClose') 
 78  					or (@name = 'htmlCreateFileParserCtxt') 
 79  					or (@name = 'inithtmlDefaultSAXHandler')
 80  					or (@name = 'xmlIsXHTML') 
 81  					or (@name = 'xmlIOHTTPOpenW') 
 82  					or (@name = 'xmlRegisterHTTPPostCallbacks') 
 83  					or (@name = 'xmlIOHTTPMatch')
 84  					or (@name = 'xmlIOHTTPOpen') 
 85  					or (@name = 'xmlIOHTTPRead') 
 86  					or (@name = 'xmlIOHTTPClose')">
 87  				<xsl:text>#ifdef LIBXML_HTML_ENABLED&nl;</xsl:text>
 88  			</xsl:if>
 89  			<xsl:if test="(@name = 'docbDefaultSAXHandlerInit') 
 90  					or (@name = 'initdocbDefaultSAXHandler')">
 91  				<xsl:text>#ifdef LIBXML_DOCB_ENABLED&nl;</xsl:text>
 92  			</xsl:if>
 93  			<xsl:if test="@name = 'xmlValidBuildContentModel'">
 94  				<xsl:text>#ifdef LIBXML_REGEXP_ENABLED&nl;</xsl:text>
 95  			</xsl:if>
 96  			<xsl:if test="(@name = 'xmlIOFTPMatch') 
 97  					or (@name = 'xmlIOFTPOpen') 
 98  					or (@name = 'xmlIOFTPRead') 
 99  					or (@name = 'xmlIOFTPClose')">
100  				<xsl:text>#ifdef LIBXML_FTP_ENABLED&nl;</xsl:text>
101  			</xsl:if>
102  			<xsl:if test="(@name = 'xmlTextReaderRelaxNGValidate') 
103  					or (@name = 'xmlTextReaderRelaxNGSetSchema')">
104  				<xsl:text>#ifdef LIBXML_SCHEMAS_ENABLED&nl;</xsl:text>
105  			</xsl:if>
106  			<xsl:if test="(@name = 'xmlXPathDebugDumpObject') 
107  					or (@name = 'xmlXPathDebugDumpCompExpr')">
108  				<xsl:text>#ifdef LIBXML_DEBUG_ENABLED&nl;</xsl:text>
109  			</xsl:if>
110  			<xsl:if test="(@name = 'xmlMallocLoc') 
111  					or (@name = 'xmlMallocAtomicLoc') 
112  					or (@name = 'xmlReallocLoc') 
113  					or (@name = 'xmlMemStrdupLoc')">
114  				<xsl:text>#ifdef DEBUG_MEMORY_LOCATION&nl;</xsl:text>
115  			</xsl:if>
116  			<!-- Symbol -->
117  			<xsl:choose>
118  				<xsl:when test="(@name = 'xmlMalloc') 
119  						or (@name = 'xmlMallocAtomic') 
120  						or (@name = 'xmlRealloc') 
121  						or (@name = 'xmlFree') 
122  						or (@name = 'xmlMemStrdup')">
123  					<xsl:text>#ifdef LIBXML_THREAD_ALLOC_ENABLED&nl;</xsl:text>
124  					<xsl:text>__</xsl:text>
125  					<xsl:value-of select="@name"/>
126  					<xsl:text>&nl;</xsl:text>
127  					<xsl:text>#else&nl;</xsl:text>
128  					<xsl:value-of select="@name"/>
129  					<xsl:text> DATA&nl;</xsl:text>
130  					<xsl:text>#endif&nl;</xsl:text>
131  				</xsl:when>
132  				<xsl:when test="(@name = 'docbDefaultSAXHandler') 
133  						or (@name = 'htmlDefaultSAXHandler') 
134  						or (@name = 'oldXMLWDcompatibility') 
135  						or (@name = 'xmlBufferAllocScheme') 
136  						or (@name = 'xmlDefaultBufferSize') 
137  						or (@name = 'xmlDefaultSAXHandler') 
138  						or (@name = 'xmlDefaultSAXLocator') 
139  						or (@name = 'xmlDoValidityCheckingDefaultValue') 
140  						or (@name = 'xmlGenericError') 
141  						or (@name = 'xmlGenericErrorContext') 
142  						or (@name = 'xmlGetWarningsDefaultValue') 
143  						or (@name = 'xmlIndentTreeOutput') 
144  						or (@name = 'xmlTreeIndentString') 
145  						or (@name = 'xmlKeepBlanksDefaultValue') 
146  						or (@name = 'xmlLineNumbersDefaultValue') 
147  						or (@name = 'xmlLoadExtDtdDefaultValue') 
148  						or (@name = 'xmlParserDebugEntities') 
149  						or (@name = 'xmlParserVersion') 
150  						or (@name = 'xmlPedanticParserDefaultValue') 
151  						or (@name = 'xmlSaveNoEmptyTags') 
152  						or (@name = 'xmlSubstituteEntitiesDefaultValue') 
153  						or (@name = 'xmlRegisterNodeDefaultValue') 
154  						or (@name = 'xmlDeregisterNodeDefaultValue')">
155  					<xsl:text>#ifdef LIBXML_THREAD_ENABLED&nl;</xsl:text>
156  					<xsl:if test="@name = 'docbDefaultSAXHandler'">
157  						<xsl:text>#ifdef LIBXML_DOCB_ENABLED&nl;</xsl:text>
158  					</xsl:if>
159  					<xsl:if test="@name = 'htmlDefaultSAXHandler'">
160  						<xsl:text>#ifdef LIBXML_HTML_ENABLED&nl;</xsl:text>
161  					</xsl:if>
162  					<xsl:text>__</xsl:text>
163  					<xsl:value-of select="@name"/>
164  					<xsl:text>&nl;</xsl:text>
165  					<xsl:if test="@name = 'docbDefaultSAXHandler'">
166  						<xsl:text>#endif&nl;</xsl:text>
167  					</xsl:if>
168  					<xsl:if test="@name = 'htmlDefaultSAXHandler'">
169  						<xsl:text>#endif&nl;</xsl:text>
170  					</xsl:if>
171  					<xsl:text>#else&nl;</xsl:text>
172  					<xsl:if test="@name = 'docbDefaultSAXHandler'">
173  						<xsl:text>#ifdef LIBXML_DOCB_ENABLED&nl;</xsl:text>
174  					</xsl:if>
175  					<xsl:if test="@name = 'htmlDefaultSAXHandler'">
176  						<xsl:text>#ifdef LIBXML_HTML_ENABLED&nl;</xsl:text>
177  					</xsl:if>
178  					<xsl:value-of select="@name"/>
179  					<xsl:text> DATA&nl;</xsl:text>
180  					<xsl:if test="@name = 'docbDefaultSAXHandler'">
181  						<xsl:text>#endif&nl;</xsl:text>
182  					</xsl:if>
183  					<xsl:if test="@name = 'htmlDefaultSAXHandler'">
184  						<xsl:text>#endif&nl;</xsl:text>
185  					</xsl:if>
186  					<xsl:text>#endif&nl;</xsl:text>
187  				</xsl:when>
188  				<xsl:otherwise>
189  					<xsl:value-of select="@name"/>
190  					<xsl:if test="self::variable">
191  						<xsl:text> DATA</xsl:text>
192  					</xsl:if>
193  					<xsl:text>&nl;</xsl:text>
194  				</xsl:otherwise>
195  			</xsl:choose>
196  			<!-- Basic tests (close) -->
197  			<xsl:if test="@file = 'c14n'">
198  				<xsl:text>#endif&nl;</xsl:text>
199  			</xsl:if>
200  			<xsl:if test="@file = 'catalog'">
201  				<xsl:text>#endif&nl;</xsl:text>
202  			</xsl:if>
203  			<xsl:if test="@file = 'debugXML'">
204  				<xsl:text>#endif&nl;</xsl:text>
205  			</xsl:if>
206  			<xsl:if test="@file = 'DOCBparser'">
207  				<xsl:text>#endif&nl;</xsl:text>
208  			</xsl:if>
209  			<xsl:if test="(@file = 'HTMLparser') 
210  					or (@file = 'HTMLtree')">
211  				<xsl:text>#endif&nl;</xsl:text>
212  			</xsl:if>
213  			<xsl:if test="@file = 'nanohttp'">
214  				<xsl:text>#endif&nl;</xsl:text>
215  			</xsl:if>
216  			<xsl:if test="@file = 'nanoftp'">
217  				<xsl:text>#endif&nl;</xsl:text>
218  			</xsl:if>
219  			<xsl:if test="(@file = 'relaxng') 
220  					or (@file = 'xmlschemas') 
221  					or (@file = 'xmlschemastypes')">
222  				<xsl:text>#endif&nl;</xsl:text>
223  			</xsl:if>
224  			<xsl:if test="@file = 'xinclude'">
225  				<xsl:text>#endif&nl;</xsl:text>
226  			</xsl:if>
227  			<xsl:if test="@file = 'xlink'">
228  				<xsl:text>#endif&nl;</xsl:text>
229  			</xsl:if>
230  			<xsl:if test="@file = 'xmlautomata'">
231  				<xsl:text>#endif&nl;</xsl:text>
232  			</xsl:if>
233  			<xsl:if test="(@file = 'xmlregexp') 
234  					or (@file = 'xmlunicode')">
235  				<xsl:text>#endif&nl;</xsl:text>
236  			</xsl:if>
237  			<xsl:if test="(@file = 'xpath') 
238  					or (@file = 'xpathInternals')">
239  				<xsl:text>#endif&nl;</xsl:text>
240  			</xsl:if>
241  			<xsl:if test="@file = 'xpointer'">
242  				<xsl:text>#endif&nl;</xsl:text>
243  			</xsl:if>
244  			<!-- Extended tests (close) -->
245  			<xsl:if test="(@name = 'htmlDefaultSAXHandlerInit') 
246  					or (@name = 'htmlInitAutoClose') 
247  					or (@name = 'htmlCreateFileParserCtxt') 
248  					or (@name = 'inithtmlDefaultSAXHandler')
249  					or (@name = 'xmlIsXHTML') 
250  					or (@name = 'xmlIOHTTPOpenW') 
251  					or (@name = 'xmlRegisterHTTPPostCallbacks') 
252  					or (@name = 'xmlIOHTTPMatch')
253  					or (@name = 'xmlIOHTTPOpen') 
254  					or (@name = 'xmlIOHTTPRead') 
255  					or (@name = 'xmlIOHTTPClose')">
256  				<xsl:text>#endif&nl;</xsl:text>
257  			</xsl:if>
258  			<xsl:if test="(@name = 'docbDefaultSAXHandlerInit') 
259  					or (@name = 'initdocbDefaultSAXHandler')">
260  				<xsl:text>#endif&nl;</xsl:text>
261  			</xsl:if>
262  			<xsl:if test="@name = 'xmlValidBuildContentModel'">
263  				<xsl:text>#endif&nl;</xsl:text>
264  			</xsl:if>
265  			<xsl:if test="(@name = 'xmlIOFTPMatch') 
266  					or (@name = 'xmlIOFTPOpen') 
267  					or (@name = 'xmlIOFTPRead') 
268  					or (@name = 'xmlIOFTPClose')">
269  				<xsl:text>#endif&nl;</xsl:text>
270  			</xsl:if>
271  			<xsl:if test="(@name = 'xmlTextReaderRelaxNGValidate') 
272  					or (@name = 'xmlTextReaderRelaxNGSetSchema')">
273  				<xsl:text>#endif&nl;</xsl:text>
274  			</xsl:if>
275  			<xsl:if test="(@name = 'xmlXPathDebugDumpObject') 
276  					or (@name = 'xmlXPathDebugDumpCompExpr')">
277  				<xsl:text>#endif&nl;</xsl:text>
278  			</xsl:if>
279  			<xsl:if test="(@name = 'xmlMallocLoc') 
280  					or (@name = 'xmlMallocAtomicLoc') 
281  					or (@name = 'xmlReallocLoc') 
282  					or (@name = 'xmlMemStrdupLoc')">
283  				<xsl:text>#endif&nl;</xsl:text>
284  			</xsl:if>
285  		</xsl:for-each>
286  	</xsl:template>
287  </xsl:stylesheet>
288