Merge lp:~zorba-coders/zorba/mz-htlm-module into lp:zorba/html-module
- mz-htlm-module
- Merge into html-module
Proposed by
Markos Zaharioudakis
Status: | Merged |
---|---|
Merged at revision: | 91 |
Proposed branch: | lp:~zorba-coders/zorba/mz-htlm-module |
Merge into: | lp:zorba/html-module |
Diff against target: |
672 lines (+317/-299) 3 files modified
src/html.xq.src/html.cpp (+68/-58) src/html.xq.src/html.h (+79/-81) src/html.xq.src/tidy_wrapper.h (+170/-160) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/mz-htlm-module |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Approve | ||
Review via email: mp+178585@code.launchpad.net |
Commit message
XmlDataManager is not a singleton any more
Description of the change
XmlDataManager is not a singleton any more
To post a comment you must log in.
Revision history for this message
Markos Zaharioudakis (markos-za) : | # |
review:
Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue succeeded - proposal merged!
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for the following merge proposals:
https:/
Progress dashboard at http://
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue result for https:/
Stage "ZorbaVQ" failed.
Check console output at http://
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/html.xq.src/html.cpp' | |||
2 | --- src/html.xq.src/html.cpp 2011-10-06 07:40:17 +0000 | |||
3 | +++ src/html.xq.src/html.cpp 2013-08-05 15:23:31 +0000 | |||
4 | @@ -25,8 +25,8 @@ | |||
5 | 25 | 25 | ||
6 | 26 | namespace zorba | 26 | namespace zorba |
7 | 27 | { | 27 | { |
10 | 28 | namespace htmlmodule | 28 | namespace htmlmodule |
11 | 29 | { | 29 | { |
12 | 30 | 30 | ||
13 | 31 | //***************************************************************************** | 31 | //***************************************************************************** |
14 | 32 | //***************************************************************************** | 32 | //***************************************************************************** |
15 | @@ -36,72 +36,80 @@ | |||
16 | 36 | { | 36 | { |
17 | 37 | } | 37 | } |
18 | 38 | 38 | ||
19 | 39 | |||
20 | 39 | ItemSequence_t | 40 | ItemSequence_t |
21 | 40 | ParseFunction::evaluate( | 41 | ParseFunction::evaluate( |
74 | 41 | const ExternalFunction::Arguments_t& aArgs, | 42 | const ExternalFunction::Arguments_t& aArgs, |
75 | 42 | const StaticContext* aSctxCtx, | 43 | const StaticContext* aSctxCtx, |
76 | 43 | const DynamicContext* aDynCtx) const | 44 | const DynamicContext* aDynCtx) const |
77 | 44 | { | 45 | { |
78 | 45 | std::auto_ptr<std::istringstream> iss; | 46 | std::auto_ptr<std::istringstream> iss; |
79 | 46 | std::istream *is; | 47 | std::istream *is; |
80 | 47 | String docString; | 48 | String docString; |
81 | 48 | Item lStringItem, lOptionsItem; | 49 | Item lStringItem, lOptionsItem; |
82 | 49 | 50 | ||
83 | 50 | if (aArgs.size() >= 1) | 51 | if (aArgs.size() >= 1) |
84 | 51 | { | 52 | { |
85 | 52 | Iterator_t lArg0Iter = aArgs[0]->getIterator(); | 53 | Iterator_t lArg0Iter = aArgs[0]->getIterator(); |
86 | 53 | lArg0Iter->open(); | 54 | lArg0Iter->open(); |
87 | 54 | lArg0Iter->next(lStringItem); | 55 | lArg0Iter->next(lStringItem); |
88 | 55 | lArg0Iter->close(); | 56 | lArg0Iter->close(); |
89 | 56 | } | 57 | } |
90 | 57 | 58 | ||
91 | 58 | if ( lStringItem.isStreamable() ) | 59 | if ( lStringItem.isStreamable() ) |
92 | 59 | { | 60 | { |
93 | 60 | // | 61 | // |
94 | 61 | // The "iss" auto_ptr can NOT be used since it will delete the stream that, | 62 | // The "iss" auto_ptr can NOT be used since it will delete the stream that, |
95 | 62 | // in this case, is a data member inside another object and not dynamically | 63 | // in this case, is a data member inside another object and not dynamically |
96 | 63 | // allocated. | 64 | // allocated. |
97 | 64 | // | 65 | // |
98 | 65 | // We can't replace "iss" with "is" since we still need the auto_ptr for | 66 | // We can't replace "iss" with "is" since we still need the auto_ptr for |
99 | 66 | // the case when the result is not streamable. | 67 | // the case when the result is not streamable. |
100 | 67 | // | 68 | // |
101 | 68 | is = &lStringItem.getStream(); | 69 | is = &lStringItem.getStream(); |
102 | 69 | } | 70 | } |
103 | 70 | else | 71 | else |
104 | 71 | { | 72 | { |
105 | 72 | docString = lStringItem.getStringValue(); | 73 | docString = lStringItem.getStringValue(); |
106 | 73 | iss.reset (new std::istringstream(docString.c_str())); | 74 | iss.reset (new std::istringstream(docString.c_str())); |
107 | 74 | is = iss.get(); | 75 | is = iss.get(); |
108 | 75 | } | 76 | } |
109 | 76 | 77 | ||
110 | 77 | if (aArgs.size() == 2) | 78 | if (aArgs.size() == 2) |
111 | 78 | { | 79 | { |
112 | 79 | Iterator_t lArg1Iter = aArgs[1]->getIterator(); | 80 | Iterator_t lArg1Iter = aArgs[1]->getIterator(); |
113 | 80 | lArg1Iter->open(); | 81 | lArg1Iter->open(); |
114 | 81 | lArg1Iter->next(lOptionsItem); | 82 | lArg1Iter->next(lOptionsItem); |
115 | 82 | lArg1Iter->close(); | 83 | lArg1Iter->close(); |
116 | 83 | } | 84 | } |
117 | 84 | 85 | ||
118 | 85 | return ItemSequence_t(new SingletonItemSequence( | 86 | return ItemSequence_t( |
119 | 86 | createHtmlItem( *is , lOptionsItem ))); | 87 | new SingletonItemSequence(createHtmlItem(*is, lOptionsItem))); |
120 | 87 | } | 88 | } |
121 | 88 | 89 | ||
122 | 89 | //***************************************************************************** | 90 | |
123 | 90 | //***************************************************************************** | 91 | //***************************************************************************** |
124 | 91 | 92 | //***************************************************************************** | |
125 | 92 | ItemFactory* HtmlModule::theFactory = 0; | 93 | HtmlModule::HtmlModule() |
126 | 94 | { | ||
127 | 95 | Zorba* engine = Zorba::getInstance(0); | ||
128 | 96 | |||
129 | 97 | theFactory = engine->getItemFactory(); | ||
130 | 98 | } | ||
131 | 99 | |||
132 | 93 | 100 | ||
133 | 94 | HtmlModule::~HtmlModule() | 101 | HtmlModule::~HtmlModule() |
134 | 95 | { | 102 | { |
135 | 96 | for ( FuncMap_t::const_iterator lIter = theFunctions.begin(); | 103 | for ( FuncMap_t::const_iterator lIter = theFunctions.begin(); |
136 | 97 | lIter != theFunctions.end(); | 104 | lIter != theFunctions.end(); |
137 | 98 | ++lIter) | 105 | ++lIter) |
142 | 99 | { | 106 | { |
143 | 100 | delete lIter->second; | 107 | delete lIter->second; |
144 | 101 | } | 108 | } |
145 | 102 | theFunctions.clear(); | 109 | theFunctions.clear(); |
146 | 103 | } | 110 | } |
147 | 104 | 111 | ||
148 | 112 | |||
149 | 105 | ExternalFunction* | 113 | ExternalFunction* |
150 | 106 | HtmlModule::getExternalFunction(const String& aLocalname) | 114 | HtmlModule::getExternalFunction(const String& aLocalname) |
151 | 107 | { | 115 | { |
152 | @@ -127,6 +135,8 @@ | |||
153 | 127 | } | 135 | } |
154 | 128 | delete this; | 136 | delete this; |
155 | 129 | } | 137 | } |
156 | 138 | |||
157 | 139 | |||
158 | 130 | //***************************************************************************** | 140 | //***************************************************************************** |
159 | 131 | //***************************************************************************** | 141 | //***************************************************************************** |
160 | 132 | 142 | ||
161 | 133 | 143 | ||
162 | === modified file 'src/html.xq.src/html.h' | |||
163 | --- src/html.xq.src/html.h 2011-10-06 07:40:17 +0000 | |||
164 | +++ src/html.xq.src/html.h 2013-08-05 15:23:31 +0000 | |||
165 | @@ -26,87 +26,85 @@ | |||
166 | 26 | { | 26 | { |
167 | 27 | namespace htmlmodule | 27 | namespace htmlmodule |
168 | 28 | { | 28 | { |
250 | 29 | //***************************************************************************** | 29 | |
251 | 30 | //***************************************************************************** | 30 | //***************************************************************************** |
252 | 31 | class HtmlModule : public ExternalModule | 31 | //***************************************************************************** |
253 | 32 | { | 32 | class HtmlModule : public ExternalModule |
254 | 33 | private: | 33 | { |
255 | 34 | static ItemFactory* theFactory; | 34 | protected: |
256 | 35 | 35 | class ltstr | |
257 | 36 | protected: | 36 | { |
258 | 37 | class ltstr | 37 | public: |
259 | 38 | { | 38 | bool operator()(const String& s1, const String& s2) const |
260 | 39 | public: | 39 | { |
261 | 40 | bool operator()(const String& s1, const String& s2) const | 40 | return s1.compare(s2) < 0; |
262 | 41 | { | 41 | } |
263 | 42 | return s1.compare(s2) < 0; | 42 | }; |
264 | 43 | } | 43 | |
265 | 44 | }; | 44 | typedef std::map<String, ExternalFunction*, ltstr> FuncMap_t; |
266 | 45 | 45 | ||
267 | 46 | typedef std::map<String, ExternalFunction*, ltstr> FuncMap_t; | 46 | protected: |
268 | 47 | 47 | ItemFactory * theFactory; | |
269 | 48 | FuncMap_t theFunctions; | 48 | XmlDataManager_t theDataMgr; |
270 | 49 | 49 | FuncMap_t theFunctions; | |
271 | 50 | public: | 50 | |
272 | 51 | virtual ~HtmlModule(); | 51 | public: |
273 | 52 | 52 | HtmlModule(); | |
274 | 53 | virtual String | 53 | |
275 | 54 | getURI() const { return "http://www.zorba-xquery.com/modules/converters/html"; } | 54 | virtual ~HtmlModule(); |
276 | 55 | 55 | ||
277 | 56 | virtual ExternalFunction* | 56 | virtual String |
278 | 57 | getExternalFunction(const String& aLocalname); | 57 | getURI() const { return "http://www.zorba-xquery.com/modules/converters/html"; } |
279 | 58 | 58 | ||
280 | 59 | virtual void | 59 | virtual ExternalFunction* |
281 | 60 | destroy(); | 60 | getExternalFunction(const String& aLocalname); |
282 | 61 | 61 | ||
283 | 62 | static ItemFactory* | 62 | virtual void |
284 | 63 | getItemFactory() | 63 | destroy(); |
285 | 64 | { | 64 | |
286 | 65 | if(!theFactory) | 65 | ItemFactory* getItemFactory() const { return theFactory; } |
287 | 66 | { | 66 | |
288 | 67 | theFactory = Zorba::getInstance(0)->getItemFactory(); | 67 | XmlDataManager* getDataMgr() const { return theDataMgr.get(); } |
289 | 68 | } | 68 | }; |
290 | 69 | return theFactory; | 69 | |
291 | 70 | } | 70 | |
292 | 71 | }; | 71 | //***************************************************************************** |
293 | 72 | 72 | //***************************************************************************** | |
294 | 73 | //***************************************************************************** | 73 | class HtmlFunction : public ContextualExternalFunction |
295 | 74 | //***************************************************************************** | 74 | { |
296 | 75 | class HtmlFunction : public ContextualExternalFunction | 75 | protected: |
297 | 76 | { | 76 | const HtmlModule* theModule; |
298 | 77 | protected: | 77 | |
299 | 78 | const HtmlModule* theModule; | 78 | public: |
300 | 79 | public: | 79 | HtmlFunction(const HtmlModule* aModule) : theModule(aModule) {}; |
301 | 80 | HtmlFunction(const HtmlModule* aModule) | 80 | |
302 | 81 | : theModule(aModule) {}; | 81 | ~HtmlFunction() {}; |
303 | 82 | 82 | ||
304 | 83 | ~HtmlFunction() {}; | 83 | virtual String |
305 | 84 | 84 | getURI() const { return theModule->getURI(); } | |
306 | 85 | virtual String | 85 | }; |
307 | 86 | getURI() const { return theModule->getURI(); } | 86 | |
308 | 87 | 87 | ||
309 | 88 | }; | 88 | //***************************************************************************** |
310 | 89 | 89 | //***************************************************************************** | |
311 | 90 | //***************************************************************************** | 90 | class ParseFunction : public HtmlFunction |
312 | 91 | //***************************************************************************** | 91 | { |
313 | 92 | class ParseFunction : public HtmlFunction | 92 | public: |
314 | 93 | { | 93 | ParseFunction(const HtmlModule* aModule); |
315 | 94 | public: | 94 | |
316 | 95 | ParseFunction(const HtmlModule* aModule); | 95 | virtual String |
317 | 96 | 96 | getLocalName() const { return "parse-internal"; } | |
318 | 97 | virtual String | 97 | |
319 | 98 | getLocalName() const { return "parse-internal"; } | 98 | virtual ItemSequence_t |
320 | 99 | 99 | evaluate(const ExternalFunction::Arguments_t& args, | |
321 | 100 | virtual ItemSequence_t | 100 | const StaticContext* aSctxCtx, |
322 | 101 | evaluate(const ExternalFunction::Arguments_t& args, | 101 | const DynamicContext* aDynCtx) const; |
323 | 102 | const StaticContext* aSctxCtx, | 102 | }; |
324 | 103 | const DynamicContext* aDynCtx) const; | 103 | |
325 | 104 | }; | 104 | |
326 | 105 | 105 | ||
327 | 106 | 106 | ||
328 | 107 | 107 | } /* namespace htmlmodule */ | |
248 | 108 | |||
249 | 109 | } /* namespace htmlmodule */ | ||
329 | 110 | } /* namespace zorba */ | 108 | } /* namespace zorba */ |
330 | 111 | 109 | ||
331 | 112 | #endif /* ZORBA_HTMLMODULE_HTML_H */ | 110 | #endif /* ZORBA_HTMLMODULE_HTML_H */ |
332 | 113 | 111 | ||
333 | === modified file 'src/html.xq.src/tidy_wrapper.h' | |||
334 | --- src/html.xq.src/tidy_wrapper.h 2011-08-18 23:42:49 +0000 | |||
335 | +++ src/html.xq.src/tidy_wrapper.h 2013-08-05 15:23:31 +0000 | |||
336 | @@ -35,166 +35,176 @@ | |||
337 | 35 | 35 | ||
338 | 36 | namespace zorba | 36 | namespace zorba |
339 | 37 | { | 37 | { |
500 | 38 | namespace htmlmodule | 38 | namespace htmlmodule |
501 | 39 | { | 39 | { |
502 | 40 | class TidyReader { | 40 | |
503 | 41 | private: | 41 | class TidyReader |
504 | 42 | std::istream* theStream; | 42 | { |
505 | 43 | // We need a buffer to support the unget function | 43 | private: |
506 | 44 | std::vector<unsigned int> theBuffer; | 44 | std::istream* theStream; |
507 | 45 | public: | 45 | // We need a buffer to support the unget function |
508 | 46 | TidyReader(std::istream* aStream) : theStream(aStream) {} | 46 | std::vector<unsigned int> theBuffer; |
509 | 47 | TidyInputSource getInputSource() | 47 | |
510 | 48 | { | 48 | public: |
511 | 49 | TidyInputSource lResult; | 49 | TidyReader(std::istream* aStream) : theStream(aStream) {} |
512 | 50 | lResult.sourceData = this; | 50 | |
513 | 51 | lResult.getByte = &getByte; | 51 | TidyInputSource getInputSource() |
514 | 52 | lResult.ungetByte = &ungetByte; | 52 | { |
515 | 53 | lResult.eof = &isEof; | 53 | TidyInputSource lResult; |
516 | 54 | return lResult; | 54 | lResult.sourceData = this; |
517 | 55 | } | 55 | lResult.getByte = &getByte; |
518 | 56 | 56 | lResult.ungetByte = &ungetByte; | |
519 | 57 | public: // callback functions | 57 | lResult.eof = &isEof; |
520 | 58 | static int TIDY_CALL getByte(void* aData) | 58 | return lResult; |
521 | 59 | { | 59 | } |
522 | 60 | TidyReader* lReader = static_cast<TidyReader*>(aData); | 60 | |
523 | 61 | if (lReader->theBuffer.empty()) | 61 | public: // callback functions |
524 | 62 | return lReader->theStream->get(); | 62 | static int TIDY_CALL getByte(void* aData) |
525 | 63 | else | 63 | { |
526 | 64 | { | 64 | TidyReader* lReader = static_cast<TidyReader*>(aData); |
527 | 65 | int lResult = lReader->theBuffer.back(); | 65 | if (lReader->theBuffer.empty()) |
528 | 66 | lReader->theBuffer.pop_back(); | 66 | return lReader->theStream->get(); |
529 | 67 | return lResult; | 67 | else |
530 | 68 | } | 68 | { |
531 | 69 | } | 69 | int lResult = lReader->theBuffer.back(); |
532 | 70 | 70 | lReader->theBuffer.pop_back(); | |
533 | 71 | static void TIDY_CALL ungetByte(void* aData, byte aByte) | 71 | return lResult; |
534 | 72 | { | 72 | } |
535 | 73 | TidyReader* lReader = static_cast<TidyReader*>(aData); | 73 | } |
536 | 74 | lReader->theBuffer.push_back(aByte); | 74 | |
537 | 75 | } | 75 | static void TIDY_CALL ungetByte(void* aData, byte aByte) |
538 | 76 | 76 | { | |
539 | 77 | static Bool TIDY_CALL isEof(void* aData) | 77 | TidyReader* lReader = static_cast<TidyReader*>(aData); |
540 | 78 | { | 78 | lReader->theBuffer.push_back(aByte); |
541 | 79 | TidyReader* lReader = static_cast<TidyReader*>(aData); | 79 | } |
542 | 80 | return lReader->theStream->eof() ? yes : no; | 80 | |
543 | 81 | } | 81 | static Bool TIDY_CALL isEof(void* aData) |
544 | 82 | }; | 82 | { |
545 | 83 | 83 | TidyReader* lReader = static_cast<TidyReader*>(aData); | |
546 | 84 | static void checkRC(int rc, const char* errMsg) | 84 | return lReader->theStream->eof() ? yes : no; |
547 | 85 | { | 85 | } |
548 | 86 | if (rc > 1) | 86 | }; |
549 | 87 | { | 87 | |
550 | 88 | zorba::Item lError = Zorba::getInstance(0)->getItemFactory() | 88 | |
551 | 89 | ->createQName( | 89 | static void checkRC(int rc, const char* errMsg) |
552 | 90 | "http://www.zorba-xquery.com/modules/converters/html", | 90 | { |
553 | 91 | "InternalError"); | 91 | if (rc > 1) |
554 | 92 | throw USER_EXCEPTION(lError, errMsg ); | 92 | { |
555 | 93 | } | 93 | zorba::Item lError = Zorba::getInstance(0)->getItemFactory()-> |
556 | 94 | } | 94 | createQName("http://www.zorba-xquery.com/modules/converters/html", |
557 | 95 | 95 | "InternalError"); | |
558 | 96 | static Bool setTidyOption(TidyDoc doc, const char* option, const char* value) | 96 | |
559 | 97 | { | 97 | throw USER_EXCEPTION(lError, errMsg ); |
560 | 98 | Bool ok = yes; | 98 | } |
561 | 99 | TidyOptionId toID = tidyOptGetIdForName(option); | 99 | } |
562 | 100 | if(toID < N_TIDY_OPTIONS) | 100 | |
563 | 101 | { | 101 | |
564 | 102 | ok = tidyOptSetValue(doc, toID, value); | 102 | static Bool setTidyOption(TidyDoc doc, const char* option, const char* value) |
565 | 103 | if (ok != yes) | 103 | { |
566 | 104 | { | 104 | Bool ok = yes; |
567 | 105 | zorba::Item lError = Zorba::getInstance(0)->getItemFactory() | 105 | TidyOptionId toID = tidyOptGetIdForName(option); |
568 | 106 | ->createQName( | 106 | if(toID < N_TIDY_OPTIONS) |
569 | 107 | "http://www.zorba-xquery.com/modules/converters/html", | 107 | { |
570 | 108 | "TidyOption"); | 108 | ok = tidyOptSetValue(doc, toID, value); |
571 | 109 | std::ostringstream lErrorMsg; | 109 | if (ok != yes) |
572 | 110 | lErrorMsg << "Error setting tidy option '" << option | 110 | { |
573 | 111 | << "' with value '" << value << "'"; | 111 | zorba::Item lError = Zorba::getInstance(0)->getItemFactory()-> |
574 | 112 | throw USER_EXCEPTION(lError, lErrorMsg.str()); | 112 | createQName("http://www.zorba-xquery.com/modules/converters/html", |
575 | 113 | } | 113 | "TidyOption"); |
576 | 114 | } | 114 | |
577 | 115 | else | 115 | std::ostringstream lErrorMsg; |
578 | 116 | { | 116 | lErrorMsg << "Error setting tidy option '" << option |
579 | 117 | return no; | 117 | << "' with value '" << value << "'"; |
580 | 118 | } | 118 | throw USER_EXCEPTION(lError, lErrorMsg.str()); |
581 | 119 | return ok; | 119 | } |
582 | 120 | } | 120 | } |
583 | 121 | 121 | else | |
584 | 122 | static Bool applyOptions(TidyDoc aDoc, zorba::Item &aOptions) | 122 | { |
585 | 123 | { | 123 | return no; |
586 | 124 | zorba::Iterator_t lAttributes, lElements; | 124 | } |
587 | 125 | zorba::Item lAttr, lElementItem, lAttrName; | 125 | return ok; |
588 | 126 | zorba::String lStrName, lStrValue; | 126 | } |
589 | 127 | Bool lRet = yes; | 127 | |
590 | 128 | 128 | ||
591 | 129 | if(!aOptions.isNull()) | 129 | static Bool applyOptions(TidyDoc aDoc, zorba::Item &aOptions) |
592 | 130 | { | 130 | { |
593 | 131 | lElements = aOptions.getChildren(); | 131 | zorba::Iterator_t lAttributes, lElements; |
594 | 132 | lElements->open(); | 132 | zorba::Item lAttr, lElementItem, lAttrName; |
595 | 133 | while (lElements->next(lElementItem) | 133 | zorba::String lStrName, lStrValue; |
596 | 134 | && lElementItem.getNodeKind () == store::StoreConsts::elementNode) | 134 | Bool lRet = yes; |
597 | 135 | { | 135 | |
598 | 136 | lAttributes = lElementItem.getAttributes(); | 136 | if(!aOptions.isNull()) |
599 | 137 | lAttributes->open(); | 137 | { |
600 | 138 | while (lAttributes->next(lAttr)) | 138 | lElements = aOptions.getChildren(); |
601 | 139 | { | 139 | lElements->open(); |
602 | 140 | lAttr.getNodeName(lAttrName); | 140 | while (lElements->next(lElementItem) |
603 | 141 | if(lAttrName.getLocalName() == "name") | 141 | && lElementItem.getNodeKind () == store::StoreConsts::elementNode) |
604 | 142 | lStrName = lAttr.getStringValue(); | 142 | { |
605 | 143 | else if(lAttrName.getLocalName() == "value") | 143 | lAttributes = lElementItem.getAttributes(); |
606 | 144 | lStrValue = lAttr.getStringValue(); | 144 | lAttributes->open(); |
607 | 145 | } | 145 | while (lAttributes->next(lAttr)) |
608 | 146 | setTidyOption(aDoc, lStrName.c_str(), lStrValue.c_str()); | 146 | { |
609 | 147 | lAttributes->close(); | 147 | lAttr.getNodeName(lAttrName); |
610 | 148 | } | 148 | if(lAttrName.getLocalName() == "name") |
611 | 149 | lElements->close(); | 149 | lStrName = lAttr.getStringValue(); |
612 | 150 | } | 150 | else if(lAttrName.getLocalName() == "value") |
613 | 151 | return lRet; | 151 | lStrValue = lAttr.getStringValue(); |
614 | 152 | } | 152 | } |
615 | 153 | 153 | setTidyOption(aDoc, lStrName.c_str(), lStrValue.c_str()); | |
616 | 154 | static zorba::Item createHtmlItem( std::istream& aStream , zorba::Item &aOptions) | 154 | lAttributes->close(); |
617 | 155 | { | 155 | } |
618 | 156 | TidyReader lReader(&aStream); | 156 | lElements->close(); |
619 | 157 | TidyInputSource lInputSource = lReader.getInputSource(); | 157 | } |
620 | 158 | 158 | return lRet; | |
621 | 159 | TidyBuffer output; | 159 | } |
622 | 160 | tidyBufInit(&output); | 160 | |
623 | 161 | TidyBuffer errbuf; | 161 | |
624 | 162 | tidyBufInit(&errbuf); | 162 | static zorba::Item createHtmlItem(std::istream& aStream , zorba::Item& aOptions) |
625 | 163 | TidyDoc tDoc = tidyCreate(); | 163 | { |
626 | 164 | 164 | TidyReader lReader(&aStream); | |
627 | 165 | applyOptions(tDoc, aOptions); | 165 | TidyInputSource lInputSource = lReader.getInputSource(); |
628 | 166 | 166 | ||
629 | 167 | int rc = -1; | 167 | TidyBuffer output; |
630 | 168 | rc = tidySetErrorBuffer(tDoc, &errbuf); | 168 | tidyBufInit(&output); |
631 | 169 | checkRC(rc, "Could not set error buffer"); | 169 | TidyBuffer errbuf; |
632 | 170 | rc = tidyParseSource(tDoc, &lInputSource); | 170 | tidyBufInit(&errbuf); |
633 | 171 | checkRC(rc, "Could not parse the source"); | 171 | TidyDoc tDoc = tidyCreate(); |
634 | 172 | rc = tidyCleanAndRepair(tDoc); | 172 | |
635 | 173 | checkRC(rc, "Could not clean and repair"); | 173 | applyOptions(tDoc, aOptions); |
636 | 174 | rc = tidyRunDiagnostics(tDoc); | 174 | |
637 | 175 | if ( rc > 1 ) | 175 | int rc = -1; |
638 | 176 | rc = ( tidyOptSetBool(tDoc, TidyForceOutput, yes) ? rc : -1 ); | 176 | rc = tidySetErrorBuffer(tDoc, &errbuf); |
639 | 177 | 177 | checkRC(rc, "Could not set error buffer"); | |
640 | 178 | // Tidy does not support streaming for output, it only supports | 178 | rc = tidyParseSource(tDoc, &lInputSource); |
641 | 179 | // something they call a "sink". Therefore we buffer it in a string. | 179 | checkRC(rc, "Could not parse the source"); |
642 | 180 | rc = tidySaveBuffer(tDoc, &output); | 180 | rc = tidyCleanAndRepair(tDoc); |
643 | 181 | checkRC(rc, "Could not save the buffer"); | 181 | checkRC(rc, "Could not clean and repair"); |
644 | 182 | std::string lResult((char*) output.bp, output.size); | 182 | rc = tidyRunDiagnostics(tDoc); |
645 | 183 | std::istringstream lStream(lResult); | 183 | if ( rc > 1 ) |
646 | 184 | 184 | rc = ( tidyOptSetBool(tDoc, TidyForceOutput, yes) ? rc : -1 ); | |
647 | 185 | tidyBufFree(&output); | 185 | |
648 | 186 | tidyBufFree(&errbuf); | 186 | // Tidy does not support streaming for output, it only supports |
649 | 187 | tidyRelease(tDoc); | 187 | // something they call a "sink". Therefore we buffer it in a string. |
650 | 188 | XmlDataManager* lDM = Zorba::getInstance(0)->getXmlDataManager(); | 188 | rc = tidySaveBuffer(tDoc, &output); |
651 | 189 | try | 189 | checkRC(rc, "Could not save the buffer"); |
652 | 190 | { | 190 | std::string lResult((char*) output.bp, output.size); |
653 | 191 | return lDM->parseXML(lStream); | 191 | std::istringstream lStream(lResult); |
654 | 192 | } catch (ZorbaException&) | 192 | |
655 | 193 | { | 193 | tidyBufFree(&output); |
656 | 194 | return NULL;//Zorba::getInstance(0)->getItemFactory()->createString(lResult); | 194 | tidyBufFree(&errbuf); |
657 | 195 | } | 195 | tidyRelease(tDoc); |
658 | 196 | } | 196 | XmlDataManager_t lDM = Zorba::getInstance(0)->getXmlDataManager(); |
659 | 197 | } /* namespace htmlmodule */ | 197 | try |
660 | 198 | { | ||
661 | 199 | return lDM->parseXML(lStream); | ||
662 | 200 | } | ||
663 | 201 | catch (ZorbaException&) | ||
664 | 202 | { | ||
665 | 203 | return NULL;//Zorba::getInstance(0)->getItemFactory()->createString(lResult); | ||
666 | 204 | } | ||
667 | 205 | } | ||
668 | 206 | |||
669 | 207 | } /* namespace htmlmodule */ | ||
670 | 198 | } /* namespace zorba */ | 208 | } /* namespace zorba */ |
671 | 199 | 209 | ||
672 | 200 | #endif //ZORBA_HTMLMODULE_TIDY_WRAPPER_H | 210 | #endif //ZORBA_HTMLMODULE_TIDY_WRAPPER_H |
Validation queue starting for the following merge proposals: /code.launchpad .net/~zorba- coders/ zorba/mz- htlm-module/ +merge/ 178585
https:/
Progress dashboard at http:// jenkins. lambda. nu/view/ ValidationQueue