1
From: YunQiang Su <wzssyqa@gmail.com>
2
Date: Mon, 28 May 2012 18:36:18 +0800
3
Subject: code fix and docs modification
6
doc/xsltproc.1 | 8 ++++++++
7
doc/xsltproc.xml | 5 +++++
8
libxslt/functions.c | 26 +++++++++++++++++++++-----
9
python/generator.py | 18 +++++++++++++-----
10
4 files changed, 47 insertions(+), 10 deletions(-)
12
diff --git a/doc/xsltproc.1 b/doc/xsltproc.1
13
index d94e7a2..328ef7b 100644
16
@@ -161,6 +161,14 @@ as described in RFC 2396 and laters\. This means, that e\.g\.
17
will maybe not work, but
21
+Also note that if there is no output to xsltproc,
23
+will not be created at all\&. An empty file will
30
\fB\-\-encoding \fR\fB\fIENCODING\fR\fR
31
diff --git a/doc/xsltproc.xml b/doc/xsltproc.xml
32
index d3849e2..a0cd77f 100644
33
--- a/doc/xsltproc.xml
34
+++ b/doc/xsltproc.xml
36
e.g. <option>-o directory</option> will maybe not work,
37
but <option>-o directory/</option> will.
40
+ Also note that if there is no output to xsltproc,
41
+ <replaceable>FILE</replaceable> will not be created at all.
42
+ An empty file will <emphasis role="bold">not</emphasis> be created.
47
diff --git a/libxslt/functions.c b/libxslt/functions.c
48
index 4720c7a..de962f4 100644
49
--- a/libxslt/functions.c
50
+++ b/libxslt/functions.c
51
@@ -654,8 +654,9 @@ xsltFormatNumberFunction(xmlXPathParserContextPtr ctxt, int nargs)
53
xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
54
xmlNodePtr cur = NULL;
62
cur = ctxt->context->node;
63
@@ -694,9 +695,24 @@ xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
64
* Okay this is ugly but should work, use the NodePtr address
67
- val = (unsigned long)((char *)cur - (char *)0);
68
- val /= sizeof(xmlNode);
69
- sprintf((char *)str, "id%ld", val);
70
+ if (cur->type != XML_NAMESPACE_DECL)
73
+ xmlNsPtr ns = (xmlNsPtr) cur;
75
+ if (ns->context != NULL)
78
+ doc = ctxt->context->doc;
82
+ val = (long)((char *)cur - (char *)doc);
84
+ sprintf((char *)str, "idp%ld", val);
86
+ sprintf((char *)str, "idm%ld", -val);
88
valuePush(ctxt, xmlXPathNewString(str));
91
diff --git a/python/generator.py b/python/generator.py
92
index 2269106..63657f1 100755
93
--- a/python/generator.py
94
+++ b/python/generator.py
97
enums = {} # { enumType: { enumConstant: enumValue } }
103
+if __name__ == "__main__":
104
+ # launched as a script
105
+ srcPref = os.path.dirname(sys.argv[0])
108
+ srcPref = os.path.dirname(__file__)
110
#######################################################################
112
# That part if purely the API acquisition phase from the
113
# XML API description
115
#######################################################################
120
@@ -442,20 +450,20 @@ def buildStubs():
124
- f = open("libxslt-api.xml")
125
+ f = open(os.path.join(srcPref,"libxslt-api.xml"))
127
(parser, target) = getparser()
132
- f = open("../doc/libxslt-api.xml")
133
+ f = open(os.path.join(srcPref,"..","doc","libxslt-api.xml"))
135
(parser, target) = getparser()
139
- print "../doc/libxslt-api.xml", ":", msg
140
+ print os.path.join(srcPref,"..","doc","libxslt-api.xml"), ":", msg
142
n = len(functions.keys())
143
print "Found %d functions in libxslt-api.xml" % (n)
144
@@ -463,7 +471,7 @@ def buildStubs():
145
py_types['pythonObject'] = ('O', "pythonObject", "pythonObject",
146
"pythonObject", "libxml_")
148
- f = open("libxslt-python-api.xml")
149
+ f = open(os.path.join(srcPref,"libxslt-python-api.xml"))
151
(parser, target) = getparser()