VirtualBox

source: vbox/trunk/src/libs/libxslt-1.1.22/python/tests/exslt.py@ 33995

Last change on this file since 33995 was 7296, checked in by vboxsync, 17 years ago

Added libxslt-1.1.22 sources.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 1.4 KB
Line 
1#!/usr/bin/python -u
2import sys
3import libxml2
4# Memory debug specific
5libxml2.debugMemory(1)
6import libxslt
7
8
9styledoc = libxml2.parseDoc(
10"""<?xml version="1.0"?>
11<xsl:stylesheet version="1.0"
12 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
13 xmlns:str="http://exslt.org/strings"
14 exclude-result-prefixes="str">
15
16<xsl:template match="/">
17<out>;
18 str:tokenize('2001-06-03T11:40:23', '-T:')
19 <xsl:copy-of select="str:tokenize('2001-06-03T11:40:23', '-T:')"/>;
20
21 str:tokenize('date math str')
22 <xsl:copy-of select="str:tokenize('date math str')"/>;
23</out>
24</xsl:template>
25
26</xsl:stylesheet>
27""")
28style = libxslt.parseStylesheetDoc(styledoc)
29doc = libxml2.parseDoc("<doc/>")
30result = style.applyStylesheet(doc, None)
31stringval = style.saveResultToString(result)
32style.freeStylesheet()
33doc.freeDoc()
34result.freeDoc()
35
36expect="""<?xml version="1.0"?>
37<out>;
38 str:tokenize('2001-06-03T11:40:23', '-T:')
39 <token>2001</token><token>06</token><token>03</token><token>11</token><token>40</token><token>23</token>;
40
41 str:tokenize('date math str')
42 <token>date</token><token>math</token><token>str</token>;
43</out>
44"""
45
46if stringval != expect:
47 print "Exslt processing failed"
48 sys.exit(255)
49
50# Memory debug specific
51libxslt.cleanup()
52if libxml2.debugMemory(1) == 0:
53 print "OK"
54else:
55 print "Memory leak %d bytes" % (libxml2.debugMemory(1))
56 libxml2.dumpMemory()
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette