Annotation of parser3/src/classes/xdoc.C, revision 1.137
1.1 parser 1: /** @file
1.2 parser 2: Parser: @b xdoc parser class.
1.1 parser 3:
1.131 paf 4: Copyright (c) 2001-2004 ArtLebedev Group (http://www.artlebedev.com)
1.85 paf 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.96 paf 6: */
1.1 parser 7:
1.111 paf 8: #include "pa_config_includes.h"
9:
1.1 parser 10: #ifdef XML
1.96 paf 11:
1.137 ! paf 12: static const char * const IDENT_XDOC_C="$Date: 2004/02/17 15:08:14 $";
1.82 paf 13:
1.69 paf 14: #include "gdome.h"
15: #include "libxml/tree.h"
1.133 paf 16: #include "libxml/HTMLtree.h"
1.69 paf 17: #include "libxslt/xsltInternals.h"
18: #include "libxslt/transform.h"
19: #include "libxslt/xsltutils.h"
1.90 paf 20: #include "libxslt/variables.h"
1.132 paf 21: #include "libxslt/imports.h"
1.111 paf 22:
23: #include "pa_vmethod_frame.h"
24:
25: #include "pa_stylesheet_manager.h"
26: #include "pa_request.h"
27: #include "pa_vxdoc.h"
28: #include "pa_charset.h"
29: #include "pa_vfile.h"
1.115 paf 30: #include "pa_xml_exception.h"
1.111 paf 31: #include "xnode.h"
32:
1.1 parser 33: // defines
34:
35: #define XDOC_CLASS_NAME "xdoc"
36:
37: #define XDOC_OUTPUT_METHOD_OPTION_NAME "method"
38: #define XDOC_OUTPUT_METHOD_OPTION_VALUE_XML "xml"
39: #define XDOC_OUTPUT_METHOD_OPTION_VALUE_HTML "html"
40: #define XDOC_OUTPUT_METHOD_OPTION_VALUE_TEXT "text"
41:
42: // class
43:
1.111 paf 44: class MXdoc: public MXnode {
1.1 parser 45: public: // VStateless_class
1.118 paf 46: Value* create_new_value(Pool&) { return new VXdoc(0, 0); }
1.1 parser 47:
48: public:
1.111 paf 49: MXdoc();
1.1 parser 50:
51: };
52:
1.111 paf 53: // global variable
54:
55: DECLARE_CLASS_VAR(xdoc, new MXdoc, 0);
1.61 paf 56:
1.65 paf 57: class xsltTransformContext_auto_ptr {
58: public:
1.67 paf 59: explicit xsltTransformContext_auto_ptr(xsltTransformContext *_APtr = 0)
60: : _Owns(_APtr != 0), _Ptr(_APtr) {}
1.65 paf 61: xsltTransformContext_auto_ptr(const xsltTransformContext_auto_ptr& _Y)
62: : _Owns(_Y._Owns), _Ptr(_Y.release()) {}
63: xsltTransformContext_auto_ptr& operator=(const xsltTransformContext_auto_ptr& _Y)
64: {if (this != &_Y)
65: {if (_Ptr != _Y.get())
66: {if (_Owns && _Ptr)
67: xsltFreeTransformContext(_Ptr);
68: _Owns = _Y._Owns; }
69: else if (_Y._Owns)
70: _Owns = true;
71: _Ptr = _Y.release(); }
72: return (*this); }
73: ~xsltTransformContext_auto_ptr()
74: {if (_Owns && _Ptr)
75: xsltFreeTransformContext(_Ptr); }
76: xsltTransformContext& operator*() const
77: {return (*get()); }
78: xsltTransformContext *operator->() const
79: {return (get()); }
80: xsltTransformContext *get() const
81: {return (_Ptr); }
82: xsltTransformContext *release() const
83: {((xsltTransformContext_auto_ptr *)this)->_Owns = false;
84: return (_Ptr); }
85: private:
86: bool _Owns;
87: xsltTransformContext *_Ptr;
88: };
1.61 paf 89:
1.65 paf 90: class xsltStylesheet_auto_ptr {
91: public:
1.67 paf 92: explicit xsltStylesheet_auto_ptr(xsltStylesheet *_APtr = 0)
93: : _Owns(_APtr != 0), _Ptr(_APtr) {}
1.65 paf 94: xsltStylesheet_auto_ptr(const xsltStylesheet_auto_ptr& _Y)
95: : _Owns(_Y._Owns), _Ptr(_Y.release()) {}
96: xsltStylesheet_auto_ptr& operator=(const xsltStylesheet_auto_ptr& _Y)
97: {if (this != &_Y)
98: {if (_Ptr != _Y.get())
99: {if (_Owns && _Ptr)
100: xsltFreeStylesheet(_Ptr);
101: _Owns = _Y._Owns; }
102: else if (_Y._Owns)
103: _Owns = true;
104: _Ptr = _Y.release(); }
105: return (*this); }
106: ~xsltStylesheet_auto_ptr()
107: {if (_Owns && _Ptr)
108: xsltFreeStylesheet(_Ptr); }
109: xsltStylesheet& operator*() const
110: {return (*get()); }
111: xsltStylesheet *operator->() const
112: {return (get()); }
113: xsltStylesheet *get() const
114: {return (_Ptr); }
115: xsltStylesheet *release() const
116: {((xsltStylesheet_auto_ptr *)this)->_Owns = false;
117: return (_Ptr); }
118: private:
119: bool _Owns;
120: xsltStylesheet *_Ptr;
121: };
1.61 paf 122:
1.1 parser 123: // methods
124:
1.111 paf 125: static void writeNode(Request& r, GdomeNode *node,
1.54 paf 126: GdomeException exc) {
127: if(!node || exc)
1.115 paf 128: throw XmlException(0, exc);
1.54 paf 129:
130: // write out result
1.111 paf 131: r.write_no_lang(*new VXnode(&r.charsets, node));
1.54 paf 132: }
133:
1.16 parser 134: // Element createElement(in DOMString tagName) raises(DOMException);
1.111 paf 135: static void _createElement(Request& r, MethodParams& params) {
136: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.16 parser 137:
1.111 paf 138: const String& tagName=params.as_string(0, "tagName must be string");
1.16 parser 139:
1.54 paf 140: GdomeException exc;
141: GdomeNode *node=
1.111 paf 142: (GdomeNode *)gdome_doc_createElement(vdoc.get_document(),
143: r.transcode(tagName).use(),
1.54 paf 144: &exc);
1.111 paf 145: writeNode(r, node, exc);
1.16 parser 146: }
147:
1.113 paf 148: // Element createElementNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException);
1.112 paf 149: static void _createElementNS(Request& r, MethodParams& params) {
150: VXdoc& vdoc=GET_SELF(r, VXdoc);
151:
152: // namespaceURI;localName
153: const String& namespaceURI=params.as_string(0, "namespaceURI must be string");
1.113 paf 154: const String& qualifiedName=params.as_string(1, "qualifiedName must be string");
1.112 paf 155:
156: GdomeException exc;
157: GdomeNode *node=
158: (GdomeNode *)gdome_doc_createElementNS(vdoc.get_document(),
159: r.transcode(namespaceURI).use(),
1.113 paf 160: r.transcode(qualifiedName).use(),
1.112 paf 161: &exc);
162: writeNode(r, node, exc);
163: }
164:
1.16 parser 165: // DocumentFragment createDocumentFragment()
1.111 paf 166: static void _createDocumentFragment(Request& r, MethodParams&) {
167: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.16 parser 168:
1.54 paf 169: GdomeException exc;
170: GdomeNode *node=
171: (GdomeNode *)gdome_doc_createDocumentFragment(
1.111 paf 172: vdoc.get_document(),
1.54 paf 173: &exc);
1.111 paf 174: writeNode(r, node, exc);
1.16 parser 175: }
176:
177: // Text createTextNode(in DOMString data);
1.111 paf 178: static void _createTextNode(Request& r, MethodParams& params) {
179: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.16 parser 180:
1.111 paf 181: const String& data=params.as_string(0, "data must be string");
1.16 parser 182:
1.54 paf 183: GdomeException exc;
184: GdomeNode *node=(GdomeNode *)gdome_doc_createTextNode(
1.111 paf 185: vdoc.get_document(),
186: r.transcode(data).use(),
1.54 paf 187: &exc);
1.111 paf 188: writeNode(r, node, exc);
1.16 parser 189: }
190:
191: // Comment createComment(in DOMString data)
1.111 paf 192: static void _createComment(Request& r, MethodParams& params) {
193: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.16 parser 194:
1.111 paf 195: const String& data=params.as_string(0, "data must be string");
1.16 parser 196:
1.54 paf 197: GdomeException exc;
198: GdomeNode *node=(GdomeNode *)gdome_doc_createComment(
1.111 paf 199: vdoc.get_document(),
200: r.transcode(data).use(),
1.54 paf 201: &exc);
1.111 paf 202: writeNode(r, node, exc);
1.16 parser 203: }
204:
205: // CDATASection createCDATASection(in DOMString data) raises(DOMException);
1.111 paf 206: static void _createCDATASection(Request& r, MethodParams& params) {
207: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.16 parser 208:
1.111 paf 209: const String& data=params.as_string(0, "data must be string");
1.16 parser 210:
1.54 paf 211: GdomeException exc;
212: GdomeNode *node=(GdomeNode *)gdome_doc_createCDATASection(
1.111 paf 213: vdoc.get_document(),
214: r.transcode(data).use(),
1.54 paf 215: &exc);
1.111 paf 216: writeNode(r, node, exc);
1.16 parser 217: }
218:
219: // ProcessingInstruction createProcessingInstruction(in DOMString target,in DOMString data) raises(DOMException);
1.111 paf 220: static void _createProcessingInstruction(Request& r, MethodParams& params) {
221: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.16 parser 222:
1.111 paf 223: const String& target=params.as_string(0, "data must be string");
224: const String& data=params.as_string(1, "data must be string");
1.16 parser 225:
1.54 paf 226: GdomeException exc;
227: GdomeNode *node=(GdomeNode *)gdome_doc_createProcessingInstruction(
1.111 paf 228: vdoc.get_document(),
229: r.transcode(target).use(),
230: r.transcode(data).use(),
1.54 paf 231: &exc);
1.111 paf 232: writeNode(r, node, exc);
1.16 parser 233: }
234:
235: // Attr createAttribute(in DOMString name) raises(DOMException);
1.111 paf 236: static void _createAttribute(Request& r, MethodParams& params) {
237: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.16 parser 238:
1.111 paf 239: const String& name=params.as_string(0, "name must be string");
1.16 parser 240:
1.54 paf 241: GdomeException exc;
242: GdomeNode *node=(GdomeNode *)gdome_doc_createAttribute(
1.111 paf 243: vdoc.get_document(),
244: r.transcode(name).use(),
1.54 paf 245: &exc);
1.111 paf 246: writeNode(r, node, exc);
1.16 parser 247: }
1.112 paf 248:
1.113 paf 249: // Attr createAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException);
1.112 paf 250: static void _createAttributeNS(Request& r, MethodParams& params) {
251: VXdoc& vdoc=GET_SELF(r, VXdoc);
252:
253: // namespaceURI;qualifiedName
254: const String& namespaceURI=params.as_string(0, "namespaceURI must be string");
255: const String& qualifiedName=params.as_string(1, "name must be string");
256:
257: GdomeException exc;
258: GdomeNode *node=(GdomeNode *)gdome_doc_createAttributeNS(
259: vdoc.get_document(),
260: r.transcode(namespaceURI).use(),
261: r.transcode(qualifiedName).use(),
262: &exc);
263: writeNode(r, node, exc);
264: }
265:
1.16 parser 266: // EntityReference createEntityReference(in DOMString name) raises(DOMException);
1.111 paf 267: static void _createEntityReference(Request& r, MethodParams& params) {
268: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.16 parser 269:
1.111 paf 270: const String& name=params.as_string(0, "name must be string");
1.16 parser 271:
1.54 paf 272: GdomeException exc;
273: GdomeNode *node=(GdomeNode *)gdome_doc_createEntityReference(
1.111 paf 274: vdoc.get_document(),
275: r.transcode(name).use(),
1.54 paf 276: &exc);
1.111 paf 277: writeNode(r, node, exc);
1.16 parser 278: }
279:
1.99 paf 280: // NodeList getElementsByTagName(in DOMString name);
1.111 paf 281: static void _getElementsByTagName(Request& r, MethodParams& params) {
282: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.99 paf 283:
1.111 paf 284: const String& name=params.as_string(0, "name must be string");
1.99 paf 285:
1.111 paf 286: VHash& result=*new VHash;
1.99 paf 287: GdomeException exc;
288: if(GdomeNodeList *nodes=
289: gdome_doc_getElementsByTagName(
1.111 paf 290: vdoc.get_document(),
291: r.transcode(name).use(),
1.99 paf 292: &exc)) {
293: gulong length=gdome_nl_length(nodes, &exc);
1.111 paf 294: for(gulong i=0; i<length; i++)
295: result.hash().put(
1.114 paf 296: String::Body::Format(i),
1.111 paf 297: new VXnode(&r.charsets, gdome_nl_item(nodes, i, &exc)));
1.99 paf 298: } else if(exc)
1.116 paf 299: throw XmlException(0, exc);
1.99 paf 300:
301: // write out result
302: r.write_no_lang(result);
303: }
304:
1.111 paf 305: static void _getElementsByTagNameNS(Request& r, MethodParams& params) {
306: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.99 paf 307:
308: // namespaceURI;localName
1.111 paf 309: const String& namespaceURI=params.as_string(0, "namespaceURI must be string");
310: const String& localName=params.as_string(1, "localName must be string");
1.99 paf 311:
312: GdomeException exc;
1.111 paf 313: VHash& result=*new VHash;
1.99 paf 314: if(GdomeNodeList *nodes=
315: gdome_doc_getElementsByTagNameNS(
1.111 paf 316: vdoc.get_document(),
317: r.transcode(namespaceURI).use(),
318: r.transcode(localName).use(),
1.99 paf 319: &exc)) {
320: gulong length=gdome_nl_length(nodes, &exc);
1.111 paf 321: for(gulong i=0; i<length; i++)
322: result.hash().put(
1.114 paf 323: String::Body::Format(i),
1.111 paf 324: new VXnode(&r.charsets, gdome_nl_item(nodes, i, &exc)));
1.99 paf 325: }
326:
327: // write out result
328: r.write_no_lang(result);
329: }
330:
1.111 paf 331: static void _getElementById(Request& r, MethodParams& params) {
332: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.16 parser 333:
1.54 paf 334: // elementId
1.111 paf 335: const String& elementId=params.as_string(0, "elementID must be string");
1.1 parser 336:
1.54 paf 337: GdomeException exc;
338: if(GdomeNode *node=(GdomeNode *)gdome_doc_getElementById(
1.111 paf 339: vdoc.get_document(),
340: r.transcode(elementId).use(),
1.54 paf 341: &exc)) {
342: // write out result
1.111 paf 343: r.write_no_lang(*new VXnode(&r.charsets, node));
1.66 paf 344: } else if(exc || xmlHaveGenericErrors())
1.116 paf 345: throw XmlException(&elementId, exc);
1.54 paf 346: }
1.79 paf 347:
1.111 paf 348: static void _importNode(Request& r, MethodParams& params) {
349: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.79 paf 350:
351: GdomeNode *importedNode=
1.111 paf 352: as_node(params, 0, "importedNode must be node");
1.79 paf 353: bool deep=
1.111 paf 354: params.as_bool(1, "deep must be bool", r);
1.79 paf 355:
356: GdomeException exc;
1.111 paf 357: GdomeNode *outputNode=gdome_doc_importNode(vdoc.get_document(),
1.79 paf 358: importedNode,
359: deep, &exc);
360: if(exc)
1.116 paf 361: throw XmlException(0, exc);
1.79 paf 362:
363: // write out result
1.111 paf 364: r.write_no_lang(*new VXnode(&r.charsets, outputNode));
1.79 paf 365: }
1.54 paf 366: /*
367: GdomeElement *gdome_doc_createElementNS (GdomeDocument *self, GdomeDOMString *namespaceURI, GdomeDOMString *qualifiedName, GdomeException *exc);
368: GdomeAttr *gdome_doc_createAttributeNS (GdomeDocument *self, GdomeDOMString *namespaceURI, GdomeDOMString *qualifiedName, GdomeException *exc);
369: */
1.1 parser 370:
1.111 paf 371: static void _create(Request& r, MethodParams& params) {
372: Charset& source_charset=r.charsets.source();
373: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.1 parser 374:
1.111 paf 375: Value& param=params[params.count()-1];
1.83 paf 376: GdomeDocument *document;
1.111 paf 377: bool set_encoding=false;
1.95 paf 378: if(param.get_junction()) { // {<?xml?>...}
1.111 paf 379: Temp_lang temp_lang(r, String::L_XML);
1.91 paf 380: const String& xml=r.process_to_string(param);
1.83 paf 381:
1.127 paf 382: const char* cstr=xml.cstr(String::L_UNSPECIFIED, 0, &r.charsets);
1.83 paf 383: document=(GdomeDocument *)
384: gdome_xml_n_mkref((xmlNode *)xmlParseMemory(
385: cstr, strlen(cstr)
386: ));
1.111 paf 387: //printf("document=0x%p\n", document);
1.83 paf 388: if(!document || xmlHaveGenericErrors()) {
389: GdomeException exc=0;
1.116 paf 390: throw XmlException(0, exc);
1.83 paf 391: }
1.111 paf 392:
393: // must be last action in if, see after if}
1.83 paf 394: } else { // [name]
395: const String& qualifiedName=param.as_string();
1.1 parser 396:
1.83 paf 397: GdomeException exc;
1.120 paf 398: #if 0
1.83 paf 399: GdomeDocumentType *documentType=gdome_di_createDocumentType (
400: docimpl,
1.111 paf 401: r.transcode(qualifiedName),
1.120 paf 402: 0/*publicId*/,
403: 0/*systemId*/,
1.83 paf 404: &exc);
405: if(!documentType || exc || xmlHaveGenericErrors())
1.87 paf 406: throw Exception(
1.111 paf 407: method_name,
1.83 paf 408: exc);
1.111 paf 409: /// +xalan createXMLDecl ?
1.120 paf 410: #endif
411: document=gdome_di_createDocument(domimpl,
1.83 paf 412: 0/*namespaceURI*/,
1.111 paf 413: r.transcode(qualifiedName).use(),
1.83 paf 414: 0/*doctype*/,
415: &exc);
416: if(!document || exc || xmlHaveGenericErrors())
1.116 paf 417: throw XmlException(0, exc);
1.103 paf 418:
1.111 paf 419: set_encoding=true;
420: // must be last action in if, see after if}
421: }
422: // must be first action after if}
423: // replace any previous parsed source
424: {
425: vdoc.set_document(&r.charsets, document);
426: GdomeException exc;
427: gdome_doc_unref(document, &exc);
1.73 paf 428: }
1.95 paf 429:
430: // URI
1.111 paf 431: const char* URI_cstr;
432: const char* URI_cstr_ptr;
433: if(params.count()>1) { // absolute(param)
434: const String& URI=params.as_string(0, "URI must be string");
435: URI_cstr=URI_cstr_ptr=r.absolute(URI).cstr();
1.95 paf 436: } else // default = disk path to requested document
1.111 paf 437: URI_cstr=r.request_info.path_translated;
1.95 paf 438: xmlDoc *doc=gdome_xml_doc_get_xmlDoc(document);
439: if(URI_cstr)
1.111 paf 440: doc->URL=source_charset.transcode_buf2xchar(URI_cstr, strlen(URI_cstr));
1.95 paf 441:
1.111 paf 442: if(set_encoding) {
443: const char* source_charset_name=source_charset.NAME().cstr();
444: doc->encoding=source_charset.transcode_buf2xchar(source_charset_name, strlen(source_charset_name));
445: }
1.9 parser 446: }
447:
1.111 paf 448: static void _load(Request& r, MethodParams& params) {
449: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.9 parser 450:
1.54 paf 451: // filespec
1.122 paf 452: const String* uri=¶ms.as_string(0, "uri must be string");
453: const char* uri_cstr;
454: if(uri->pos("://")==STRING_NOT_FOUND) // disk path
455: uri_cstr=r.absolute(*uri).cstr(String::L_FILE_SPEC);
456: else // xxx://
457: uri_cstr=uri->cstr(String::L_AS_IS); // leave as-is for xmlParseFile to handle
1.105 paf 458:
1.122 paf 459: /// todo!! add SAFE MODE!!
1.73 paf 460: GdomeDocument *document=(GdomeDocument *)
1.123 paf 461: gdome_xml_n_mkref((xmlNode *)xmlParseFile(uri_cstr));
1.73 paf 462: if(!document || xmlHaveGenericErrors()) {
463: GdomeException exc=0;
1.122 paf 464: throw XmlException(uri, exc);
1.111 paf 465: }
466: // must be first action after if}
467: // replace any previous parsed source
468: {
469: vdoc.set_document(&r.charsets, document);
470: GdomeException exc;
471: gdome_doc_unref(document, &exc);
1.73 paf 472: }
1.122 paf 473: /* xmlParseFile does that itself. old peace for xmlParseMemory
474: const char* URI_cstr=uri->cstr();
1.107 paf 475: xmlDoc *doc=gdome_xml_doc_get_xmlDoc(document);
476: if(URI_cstr)
1.111 paf 477: doc->URL=r.charsets.source().transcode_buf2xchar(URI_cstr, strlen(URI_cstr));
1.122 paf 478: */
1.9 parser 479: }
480:
1.111 paf 481: static void param_option_over_output_option(
482: HashStringValue& param_options, const char* option_name,
483: const String*& output_option) {
1.114 paf 484: if(Value* value=param_options.get(String::Body(option_name)))
1.61 paf 485: output_option=&value->as_string();
1.46 paf 486: }
1.111 paf 487: static void param_option_over_output_option(
488: HashStringValue& param_options, const char* option_name,
489: bool& output_option) {
1.114 paf 490: if(Value* value=param_options.get(String::Body(option_name))) {
1.46 paf 491: const String& s=value->as_string();
492: if(s=="yes")
493: output_option=true;
494: else if(s=="no")
495: output_option=false;
496: else
1.87 paf 497: throw Exception("parser.runtime",
1.46 paf 498: &s,
499: "%s must be either 'yes' or 'no'", option_name);
500: }
501: }
502:
1.100 paf 503: /// @test valid_options check
1.111 paf 504: static void prepare_output_options(Request& r,
505: MethodParams& params, size_t index,
506: VXdoc::Output_options& oo) {
1.46 paf 507: /*
508: <xsl:output
509: !method = "xml" | "html" | "text" | qname-but-not-ncname
510: !version = nmtoken
511: !encoding = string
512: !omit-xml-declaration = "yes" | "no"
513: !standalone = "yes" | "no"
514: !doctype-public = string
515: !doctype-system = string
516: cdata-section-elements = qnames
517: !indent = "yes" | "no"
518: !media-type = string />
1.61 paf 519: */
1.1 parser 520:
1.46 paf 521: // configuring with options from parameter...
1.111 paf 522: if(params.count()>index) {
523: Value& voptions=params.as_no_junction(index, "options must be string");
1.1 parser 524: if(voptions.is_defined()) {
1.111 paf 525: if(HashStringValue *options=voptions.get_hash()) {
1.1 parser 526: // $.method[xml|html|text]
1.114 paf 527: if(Value* vmethod=options->get(String::Body(XDOC_OUTPUT_METHOD_OPTION_NAME)))
1.61 paf 528: oo.method=&vmethod->as_string();
1.1 parser 529:
1.46 paf 530: // $.version[1.0]
1.111 paf 531: param_option_over_output_option(*options, "version", oo.version);
1.1 parser 532: // $.encoding[windows-1251|...]
1.111 paf 533: param_option_over_output_option(*options, "encoding", oo.encoding);
1.46 paf 534: // $.omit-xml-declaration[yes|no]
1.111 paf 535: param_option_over_output_option(*options, "omit-xml-declaration", oo.omitXmlDeclaration);
1.46 paf 536: // $.standalone[yes|no]
1.111 paf 537: param_option_over_output_option(*options, "standalone", oo.standalone);
1.46 paf 538: // $.indent[yes|no]
1.111 paf 539: param_option_over_output_option(*options, "indent", oo.indent);
1.46 paf 540: // $.media-type[text/{html|xml|plain}]
1.111 paf 541: param_option_over_output_option(*options, "media-type", oo.mediaType);
1.19 parser 542: }
1.1 parser 543: }
544: }
545:
1.46 paf 546: // default encoding from pool
1.61 paf 547: if(!oo.encoding)
1.111 paf 548: oo.encoding=new String(r.charsets.source().NAME(), String::L_TAINTED);
1.46 paf 549: // default method=xml
550: if(!oo.method)
1.111 paf 551: oo.method=new String(XDOC_OUTPUT_METHOD_OPTION_VALUE_XML);
1.61 paf 552: // default mediaType = depending on method
553: if(!oo.mediaType) {
554: if(*oo.method==XDOC_OUTPUT_METHOD_OPTION_VALUE_XML)
1.111 paf 555: oo.mediaType=new String("text/xml");
1.61 paf 556: else if(*oo.method==XDOC_OUTPUT_METHOD_OPTION_VALUE_HTML)
1.111 paf 557: oo.mediaType=new String("text/html");
1.61 paf 558: else // XDOC_OUTPUT_METHOD_OPTION_VALUE_TEXT & all others
1.111 paf 559: oo.mediaType=new String("text/plain");
1.61 paf 560: }
561: }
1.46 paf 562:
1.133 paf 563: /// patching piece from libxslt not to set meta encoding
1.134 paf 564: static void
565: pa_xsltSaveResultToMem(
566: xmlChar*& doc_txt_ptr, int& doc_txt_len,
567: xmlDocPtr result,
568: xsltStylesheetPtr style,
569: xmlCharEncodingHandler* encoder)
570: {
1.133 paf 571: const xmlChar *encoding;
572: int base;
573: const xmlChar *method;
574: int indent;
1.134 paf 575: xmlOutputBufferPtr buf = 0;
1.133 paf 576:
1.134 paf 577: if ((result == NULL) || (style == NULL))
578: return;
1.133 paf 579: if ((result->children == NULL) ||
580: ((result->children->type == XML_DTD_NODE) &&
581: (result->children->next == NULL)))
1.134 paf 582: return;
1.133 paf 583:
584: if ((style->methodURI != NULL) &&
585: ((style->method == NULL) ||
586: (!xmlStrEqual(style->method, (const xmlChar *) "xhtml")))) {
587: xsltGenericError(xsltGenericErrorContext,
588: "xsltSaveResultTo : unknown ouput method\n");
1.134 paf 589: return;
1.133 paf 590: }
591:
592: XSLT_GET_IMPORT_PTR(method, style, method)
593: XSLT_GET_IMPORT_PTR(encoding, style, encoding)
594: XSLT_GET_IMPORT_INT(indent, style, indent);
595:
596: if ((method == NULL) && (result->type == XML_HTML_DOCUMENT_NODE))
597: method = (const xmlChar *) "html";
598:
599: if ((method != NULL) &&
1.134 paf 600: (xmlStrEqual(method, (const xmlChar *) "html")
601: ||xmlStrEqual(method, (const xmlChar *) "xhtml"))) {
1.133 paf 602: if (indent == -1)
603: indent = 1;
1.136 paf 604: //
605: // * xmlDocDumpFormatMemoryEnc:
606: // Note it is up to the caller of this function to free the
607: // allocated memory with xmlFree()
608: //
609: // we wont free anything, and wont copy that data anymore [already done inside and zeroterminated]
1.134 paf 610: xmlDocDumpFormatMemoryEnc(result, &doc_txt_ptr, &doc_txt_len, (const char *) encoding,
1.133 paf 611: indent);
612: } else if ((method != NULL) &&
613: (xmlStrEqual(method, (const xmlChar *) "text"))) {
614: xmlNodePtr cur;
1.134 paf 615: buf = xmlAllocOutputBuffer(encoder);
1.133 paf 616:
617: cur = result->children;
618: while (cur != NULL) {
619: if (cur->type == XML_TEXT_NODE)
620: xmlOutputBufferWriteString(buf, (const char *) cur->content);
621:
622: /*
623: * Skip to next node
624: */
625: if (cur->children != NULL) {
626: if ((cur->children->type != XML_ENTITY_DECL) &&
627: (cur->children->type != XML_ENTITY_REF_NODE) &&
628: (cur->children->type != XML_ENTITY_NODE)) {
629: cur = cur->children;
630: continue;
631: }
632: }
633: if (cur->next != NULL) {
634: cur = cur->next;
635: continue;
636: }
637:
638: do {
639: cur = cur->parent;
640: if (cur == NULL)
641: break;
642: if (cur == (xmlNodePtr) style->doc) {
643: cur = NULL;
644: break;
645: }
646: if (cur->next != NULL) {
647: cur = cur->next;
648: break;
649: }
650: } while (cur != NULL);
651: }
652: } else {
653: int omitXmlDecl;
654: int standalone;
1.134 paf 655: buf = xmlAllocOutputBuffer(encoder);
1.133 paf 656:
657: XSLT_GET_IMPORT_INT(omitXmlDecl, style, omitXmlDeclaration);
658: XSLT_GET_IMPORT_INT(standalone, style, standalone);
659:
660: if (omitXmlDecl != 1) {
661: xmlOutputBufferWriteString(buf, "<?xml version=");
662: if (result->version != NULL)
663: xmlBufferWriteQuotedString(buf->buffer, result->version);
664: else
665: xmlOutputBufferWriteString(buf, "\"1.0\"");
666: if (encoding == NULL) {
667: if (result->encoding != NULL)
668: encoding = result->encoding;
669: else if (result->charset != XML_CHAR_ENCODING_UTF8)
670: encoding = (const xmlChar *)
671: xmlGetCharEncodingName((xmlCharEncoding)
672: result->charset);
673: }
674: if (encoding != NULL) {
675: xmlOutputBufferWriteString(buf, " encoding=");
676: xmlBufferWriteQuotedString(buf->buffer, (xmlChar *) encoding);
677: }
678: switch (standalone) {
679: case 0:
680: xmlOutputBufferWriteString(buf, " standalone=\"no\"");
681: break;
682: case 1:
683: xmlOutputBufferWriteString(buf, " standalone=\"yes\"");
684: break;
685: default:
686: break;
687: }
688: xmlOutputBufferWriteString(buf, "?>\n");
689: }
690: if (result->children != NULL) {
691: xmlNodePtr child = result->children;
692:
693: while (child != NULL) {
694: xmlNodeDumpOutput(buf, result, child, 0, (indent == 1),
695: (const char *) encoding);
696: if (child->type == XML_DTD_NODE)
697: xmlOutputBufferWriteString(buf, "\n");
698: child = child->next;
699: }
700: xmlOutputBufferWriteString(buf, "\n");
701: }
702: }
1.134 paf 703:
704: if(buf) {
705: xmlOutputBufferFlush(buf);
706: if(buf->conv) {
707: doc_txt_len=buf->conv->use;
708: doc_txt_ptr=buf->conv->content;
709: } else {
710: doc_txt_len=buf->buffer->use;
711: doc_txt_ptr=buf->buffer->content;
712: }
713:
1.136 paf 714: if(doc_txt_ptr && doc_txt_len)
715: doc_txt_ptr=BAD_CAST pa_strdup((const char*)doc_txt_ptr, doc_txt_len);
1.134 paf 716:
717: xmlOutputBufferClose(buf);
1.136 paf 718: }
1.133 paf 719: }
720:
1.111 paf 721: struct Xdoc2buf_result {
722: char* str;
723: size_t length;
724: };
725: static Xdoc2buf_result xdoc2buf(Request& r, VXdoc& vdoc,
726: MethodParams& params, int index,
1.63 paf 727: VXdoc::Output_options& oo,
1.111 paf 728: const String* file_spec) {
729: Xdoc2buf_result result;
730: prepare_output_options(r, params, index,
1.61 paf 731: oo);
732:
1.111 paf 733: const char* encoding_cstr=oo.encoding->cstr();
1.63 paf 734: xmlCharEncodingHandler *encoder=xmlFindCharEncodingHandler(encoding_cstr);
735: if(!encoder)
1.87 paf 736: throw Exception("parser.runtime",
1.111 paf 737: 0,
1.63 paf 738: "encoding '%s' not supported", encoding_cstr);
1.61 paf 739: // UTF-8 encoder contains empty input/output converters,
740: // which is wrong for xmlOutputBufferCreateIO
741: // while zero encoder goes perfectly
1.130 paf 742: const char* encoder_name=encoder->name;
743: if(strcmp(encoder_name, "UTF-8")==0)
1.61 paf 744: encoder=0;
745:
1.65 paf 746: xsltStylesheet_auto_ptr stylesheet(xsltNewStylesheet());
747: if(!stylesheet.get())
1.87 paf 748: throw Exception(0,
1.111 paf 749: 0,
1.61 paf 750: "xsltNewStylesheet failed");
751:
1.62 paf 752: #define OOS2STYLE(name) \
1.111 paf 753: stylesheet->name=oo.name?BAD_CAST xmlMemStrdup(r.transcode(*oo.name)->str):0
1.62 paf 754: #define OOE2STYLE(name) \
755: stylesheet->name=oo.name
1.61 paf 756:
1.62 paf 757: OOS2STYLE(method);
758: OOS2STYLE(encoding);
759: OOS2STYLE(mediaType);
1.124 paf 760: // OOS2STYLE(doctypeSystem);
1.130 paf 761: // OOS2STYLE(doctypePublic);
1.62 paf 762: OOE2STYLE(indent);
763: OOS2STYLE(version);
764: OOE2STYLE(standalone);
765: OOE2STYLE(omitXmlDeclaration);
1.61 paf 766:
1.111 paf 767: xmlDoc *document=gdome_xml_doc_get_xmlDoc(vdoc.get_document());
1.130 paf 768: document->encoding=BAD_CAST xmlMemStrdup(encoder_name);
1.134 paf 769:
1.135 paf 770: xmlChar* doc_txt_ptr=0;
771: int doc_txt_len=0;
1.134 paf 772: pa_xsltSaveResultToMem(doc_txt_ptr, doc_txt_len, document, stylesheet.get(), encoder);
773: if(xmlHaveGenericErrors()) {
1.75 paf 774: GdomeException exc=0;
1.116 paf 775: throw XmlException(0, exc);
1.75 paf 776: }
1.61 paf 777:
1.134 paf 778: result.length=doc_txt_len;
779: result.str=(char*)doc_txt_ptr;
1.118 paf 780:
1.63 paf 781: if(file_spec)
1.111 paf 782: file_write(*file_spec,
1.134 paf 783: result.str, result.length,
1.111 paf 784: true/*as_text*/);
785:
786: return result;
1.1 parser 787: }
788:
1.111 paf 789: static void _file(Request& r, MethodParams& params) {
790: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.63 paf 791: VXdoc::Output_options oo(vdoc.output_options);
1.111 paf 792: Xdoc2buf_result buf=xdoc2buf(r, vdoc, params, 0,
1.63 paf 793: oo,
1.111 paf 794: 0/*not to file, to memory*/);
1.63 paf 795: // write out result
1.111 paf 796: r.write_no_lang(String(buf.str, buf.length));
1.1 parser 797:
1.58 paf 798: // write out result
1.111 paf 799: VFile& vfile=*new VFile;
800: VHash& vhcontent_type=*new VHash;
801: vhcontent_type.hash().put(
802: value_name,
803: new VString(*oo.mediaType));
804: vhcontent_type.hash().put(
1.126 paf 805: String::Body("charset"),
1.111 paf 806: new VString(*oo.encoding));
807:
808: vfile.set(false/*tainted*/, buf.str?buf.str:""/*to distinguish from stat-ed file*/, buf.length,
809: 0/*file_name*/, &vhcontent_type);
1.58 paf 810: r.write_no_lang(vfile);
1.63 paf 811: }
812:
1.111 paf 813: static void _save(Request& r, MethodParams& params) {
814: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.63 paf 815:
1.111 paf 816: const String& file_spec=r.absolute(params.as_string(0, "file name must be string"));
1.63 paf 817:
818: VXdoc::Output_options oo(vdoc.output_options);
1.111 paf 819: xdoc2buf(r, vdoc, params, 1,
1.63 paf 820: oo,
1.111 paf 821: &file_spec);
1.63 paf 822: }
823:
1.111 paf 824: static void _string(Request& r, MethodParams& params) {
825: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.63 paf 826: VXdoc::Output_options oo(vdoc.output_options);
1.111 paf 827: Xdoc2buf_result buf=xdoc2buf(r, vdoc, params, 0,
1.63 paf 828: oo,
1.111 paf 829: 0/*not to file, to memory*/);
1.63 paf 830: // write out result
1.111 paf 831: r.write_no_lang(String(buf.str, buf.length));
1.1 parser 832: }
1.58 paf 833:
1.111 paf 834: #ifndef DOXYGEN
835: struct Add_xslt_param_info {
836: Request* r;
837: Array<GdomeDOMString_auto_ptr>* strings;
838: const char** current_transform_param;
839: };
840: #endif
841: static void add_xslt_param(
842: HashStringValue::key_type attribute,
843: HashStringValue::value_type meaning,
844: Add_xslt_param_info* info) {
845: GdomeDOMString_auto_ptr s;
846: *info->current_transform_param++=(s=info->r->transcode(attribute))->str; *info->strings+=s;
847: *info->current_transform_param++=(s=info->r->transcode(meaning->as_string()))->str; *info->strings+=s;
848: }
1.132 paf 849:
1.111 paf 850: static VXdoc& _transform(Request& r, const String* stylesheet_source,
1.132 paf 851: VXdoc& vdoc, xsltStylesheetPtr stylesheet, const char** transform_params)
852: {
1.111 paf 853: xmlDoc *document=gdome_xml_doc_get_xmlDoc(vdoc.get_document());
1.65 paf 854: xsltTransformContext_auto_ptr transformContext(
855: xsltNewTransformContext(stylesheet, document));
1.90 paf 856: // make params literal
1.111 paf 857: if (transformContext->globalVars == NULL) // strangly not initialized by xsltNewTransformContext
1.90 paf 858: transformContext->globalVars = xmlHashCreate(20);
859: xsltQuoteUserParams(transformContext.get(), transform_params);
860: // do transform
1.59 paf 861: xmlDoc *transformed=xsltApplyStylesheetUser(
862: stylesheet,
863: document,
1.90 paf 864: 0/*already quoted-inserted transform_params*/,
1.111 paf 865: 0/*const char* output*/,
1.59 paf 866: 0/*FILE *profile*/,
1.65 paf 867: transformContext.get());
1.66 paf 868: if(!transformed || xmlHaveGenericErrors()) {
869: GdomeException exc=0;
1.116 paf 870: throw XmlException(stylesheet_source, exc);
1.66 paf 871: }
1.42 paf 872:
1.61 paf 873: //gdome_xml_doc_mkref dislikes XML_HTML_DOCUMENT_NODE type, fixing
874: transformed->type=XML_DOCUMENT_NODE;
1.59 paf 875: // constructing result
876: GdomeDocument *gdomeDocument=gdome_xml_doc_mkref(transformed);
877: if(!gdomeDocument)
1.87 paf 878: throw Exception(0,
1.111 paf 879: 0,
1.59 paf 880: "gdome_xml_doc_mkref failed");
1.111 paf 881: VXdoc& result=*new VXdoc(&r.charsets, gdomeDocument);
1.61 paf 882: /* grabbing options
883:
884: <xsl:output
885: !method = "xml" | "html" | "text"
886: X| qname-but-not-ncname
887: !version = nmtoken
888: !encoding = string
889: !omit-xml-declaration = "yes" | "no"
890: !standalone = "yes" | "no"
891: !doctype-public = string
892: !doctype-system = string
893: Xcdata-section-elements = qnames
894: !indent = "yes" | "no"
895: !media-type = string />
1.59 paf 896: */
897: VXdoc::Output_options& oo=result.output_options;
898:
1.111 paf 899: oo.method=stylesheet->method?&r.transcode(stylesheet->method):0;
900: oo.encoding=stylesheet->encoding?&r.transcode(stylesheet->encoding):0;
901: oo.mediaType=stylesheet->mediaType?&r.transcode(stylesheet->mediaType):0;
1.59 paf 902: oo.indent=stylesheet->indent!=0;
1.111 paf 903: oo.version=stylesheet->version?&r.transcode(stylesheet->version):0;
1.59 paf 904: oo.standalone=stylesheet->standalone!=0;
905: oo.omitXmlDeclaration=stylesheet->omitXmlDeclaration!=0;
906:
1.93 paf 907: // return
908: return result;
909: }
1.111 paf 910: static void _transform(Request& r, MethodParams& params) {
911: VXdoc& vdoc=GET_SELF(r, VXdoc);
1.93 paf 912:
913: // params
1.111 paf 914: Array<GdomeDOMString_auto_ptr> transform_strings;
915: const char** transform_params=0;
916: if(params.count()>1) {
917: Value& vparams=params.as_no_junction(1, "transform parameters must be hash");
1.106 paf 918: if(!vparams.is_string())
1.111 paf 919: if(HashStringValue* hash=vparams.get_hash()) {
920: transform_params=new(UseGC) const char*[hash->count()*2+1];
921: Add_xslt_param_info info={
922: &r,
923: &transform_strings,
924: transform_params
925: };
926: hash->for_each(add_xslt_param, &info);
927: transform_params[hash->count()*2]=0;
1.93 paf 928: } else
929: throw Exception("parser.runtime",
1.111 paf 930: 0,
1.93 paf 931: "transform parameters parameter must be hash");
932: }
933:
1.111 paf 934: VXdoc* result;
935: if(Value *vxdoc=params[0].as(VXDOC_TYPE, false)) { // stylesheet (xdoc)
1.93 paf 936: xmlDoc *document=gdome_xml_doc_get_xmlDoc(
1.111 paf 937: static_cast<VXdoc *>(vxdoc)->get_document());
1.93 paf 938: // compile xdoc stylesheet
1.94 paf 939: xsltStylesheet_auto_ptr stylesheet_ptr(xsltParseStylesheetDoc(document));
1.93 paf 940: if(xmlHaveGenericErrors()) {
941: GdomeException exc=0;
1.116 paf 942: throw XmlException(0, exc);
1.93 paf 943: }
944: if(!stylesheet_ptr.get())
945: throw Exception("xml",
1.111 paf 946: 0,
1.93 paf 947: "stylesheet failed to compile");
1.128 paf 948: // strange thing - xsltParseStylesheetDoc records document and destroys it in stylesheet destructor
949: // we don't need that
950: stylesheet_ptr->doc=0;
1.93 paf 951:
952: // transform!
1.111 paf 953: result=&_transform(r, 0,
1.93 paf 954: vdoc, stylesheet_ptr.get(),
955: transform_params);
956: } else { // stylesheet (file name)
957: // extablish stylesheet connection
958: const String& stylesheet_filespec=
1.111 paf 959: r.absolute(params.as_string(0, "stylesheet must be file name (string) or DOM document (xdoc)"));
1.125 paf 960: Stylesheet_connection_ptr connection=stylesheet_manager->get_connection(stylesheet_filespec);
1.93 paf 961:
962: // load and compile file to stylesheet [or get cached if any]
963: // transform!
1.122 paf 964: result=&_transform(r, &stylesheet_filespec, vdoc, connection->stylesheet(),
1.93 paf 965: transform_params);
966: }
967:
1.59 paf 968: // write out result
1.93 paf 969: r.write_no_lang(*result);
1.1 parser 970: }
971:
1.16 parser 972: // constructor
1.2 parser 973:
1.92 paf 974: /// @test how to create empty type html?
1.111 paf 975: MXdoc::MXdoc(): MXnode(XDOC_CLASS_NAME, xnode_class) {
1.16 parser 976: /// DOM1
1.2 parser 977:
1.16 parser 978: // Element createElement(in DOMString tagName) raises(DOMException);
979: add_native_method("createElement", Method::CT_DYNAMIC, _createElement, 1, 1);
980: // DocumentFragment createDocumentFragment();
981: add_native_method("createDocumentFragment", Method::CT_DYNAMIC, _createDocumentFragment, 0, 0);
982: // Text createTextNode(in DOMString data);
983: add_native_method("createTextNode", Method::CT_DYNAMIC, _createTextNode, 1, 1);
984: // Comment createComment(in DOMString data);
985: add_native_method("createComment", Method::CT_DYNAMIC, _createComment, 1, 1);
986: // CDATASection createCDATASection(in DOMString data) raises(DOMException);
987: add_native_method("createCDATASection", Method::CT_DYNAMIC, _createCDATASection, 1, 1);
988: // ProcessingInstruction createProcessingInstruction(in DOMString target, in DOMString data) raises(DOMException);
989: add_native_method("createProcessingInstruction", Method::CT_DYNAMIC, _createProcessingInstruction, 2, 2);
990: // Attr createAttribute(in DOMString name) raises(DOMException);
991: add_native_method("createAttribute", Method::CT_DYNAMIC, _createAttribute, 1, 1);
992: // EntityReference createEntityReference(in DOMString name) raises(DOMException);
993: add_native_method("createEntityReference", Method::CT_DYNAMIC, _createEntityReference, 1, 1);
1.99 paf 994: // NodeList getElementsByTagName(in DOMString name);
995: add_native_method("getElementsByTagName", Method::CT_DYNAMIC, _getElementsByTagName, 1, 1);
1.2 parser 996:
1.79 paf 997: /// DOM2
1.2 parser 998:
1.16 parser 999: // ^xdoc.getElementById[elementId]
1000: add_native_method("getElementById", Method::CT_DYNAMIC, _getElementById, 1, 1);
1.79 paf 1001:
1002: // Node (in Node importedNode, in boolean deep) raises(DOMException)
1003: add_native_method("importNode", Method::CT_DYNAMIC, _importNode, 2, 2);
1.112 paf 1004:
1.113 paf 1005: // Attr createAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException);
1.112 paf 1006: add_native_method("createAttributeNS", Method::CT_DYNAMIC, _createAttributeNS, 2, 2);
1007:
1.113 paf 1008: // Element createElementNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException);
1.112 paf 1009: add_native_method("createElementNS", Method::CT_DYNAMIC, _createElementNS, 2, 2);
1.99 paf 1010:
1011: // NodeList getElementsByTagNameNS(in DOMString namespaceURI, in DOMString localName);
1012: add_native_method("getElementsByTagNameNS", Method::CT_DYNAMIC, _getElementsByTagNameNS, 2, 2);
1.1 parser 1013:
1.16 parser 1014: /// parser
1015:
1.54 paf 1016: // ^xdoc::create{qualifiedName}
1.95 paf 1017: // ^xdoc::create[<some>xml</some>]
1018: // ^xdoc::create[URI][<some>xml</some>]
1019: add_native_method("create", Method::CT_DYNAMIC, _create, 1, 2);
1.83 paf 1020: // for backward compatibility with <=v 1.82 2002/01/31 11:51:46 paf
1021: add_native_method("set", Method::CT_DYNAMIC, _create, 1, 1);
1.54 paf 1022:
1023: // ^xdoc::load[some.xml]
1.122 paf 1024: add_native_method("load", Method::CT_DYNAMIC, _load, 1, 1);
1.54 paf 1025:
1.2 parser 1026: // ^xdoc.save[some.xml]
1027: // ^xdoc.save[some.xml;options hash]
1.1 parser 1028: add_native_method("save", Method::CT_DYNAMIC, _save, 1, 2);
1029:
1.2 parser 1030: // ^xdoc.string[] <doc/>
1031: // ^xdoc.string[options hash] <doc/>
1.1 parser 1032: add_native_method("string", Method::CT_DYNAMIC, _string, 0, 1);
1033:
1.2 parser 1034: // ^xdoc.file[] file with "<doc/>"
1035: // ^xdoc.file[options hash] file with "<doc/>"
1.58 paf 1036: add_native_method("file", Method::CT_DYNAMIC, _file, 0, 1);
1.1 parser 1037:
1.98 paf 1038: // ^xdoc.transform[stylesheet file_name/xdoc]
1039: // ^xdoc.transform[stylesheet file_name/xdoc;params hash]
1.59 paf 1040: add_native_method("transform", Method::CT_DYNAMIC, _transform, 1, 2);
1.2 parser 1041:
1.5 parser 1042: }
1043:
1.111 paf 1044: # else
1045:
1046: #include "classes.h"
1047:
1.1 parser 1048: // global variable
1049:
1.111 paf 1050: DECLARE_CLASS_VAR(xdoc, 0, 0); // fictive
1.1 parser 1051:
1052: #endif
E-mail: