diff options
author | Bruce Momjian | 2012-06-10 19:20:04 +0000 |
---|---|---|
committer | Bruce Momjian | 2012-06-10 19:20:04 +0000 |
commit | 927d61eeff78363ea3938c818d07e511ebaf75cf (patch) | |
tree | 2f0bcecf53327f76272a8ce690fa62505520fab9 /contrib/xml2 | |
parent | 60801944fa105252b48ea5688d47dfc05c695042 (diff) |
Run pgindent on 9.2 source tree in preparation for first 9.3
commit-fest.
Diffstat (limited to 'contrib/xml2')
-rw-r--r-- | contrib/xml2/xpath.c | 214 | ||||
-rw-r--r-- | contrib/xml2/xslt_proc.c | 54 |
2 files changed, 134 insertions, 134 deletions
diff --git a/contrib/xml2/xpath.c b/contrib/xml2/xpath.c index 2ddee59fcb7..660d25c3490 100644 --- a/contrib/xml2/xpath.c +++ b/contrib/xml2/xpath.c @@ -702,126 +702,126 @@ xpath_table(PG_FUNCTION_ARGS) PG_TRY(); { - /* For each row i.e. document returned from SPI */ - for (i = 0; i < proc; i++) - { - char *pkey; - char *xmldoc; - xmlXPathContextPtr ctxt; - xmlXPathObjectPtr res; - xmlChar *resstr; - xmlXPathCompExprPtr comppath; - - /* Extract the row data as C Strings */ - spi_tuple = tuptable->vals[i]; - pkey = SPI_getvalue(spi_tuple, spi_tupdesc, 1); - xmldoc = SPI_getvalue(spi_tuple, spi_tupdesc, 2); - - /* - * Clear the values array, so that not-well-formed documents return - * NULL in all columns. Note that this also means that spare columns - * will be NULL. - */ - for (j = 0; j < ret_tupdesc->natts; j++) - values[j] = NULL; - - /* Insert primary key */ - values[0] = pkey; - - /* Parse the document */ - if (xmldoc) - doctree = xmlParseMemory(xmldoc, strlen(xmldoc)); - else /* treat NULL as not well-formed */ - doctree = NULL; - - if (doctree == NULL) + /* For each row i.e. document returned from SPI */ + for (i = 0; i < proc; i++) { - /* not well-formed, so output all-NULL tuple */ - ret_tuple = BuildTupleFromCStrings(attinmeta, values); - tuplestore_puttuple(tupstore, ret_tuple); - heap_freetuple(ret_tuple); - } - else - { - /* New loop here - we have to deal with nodeset results */ - rownr = 0; - - do + char *pkey; + char *xmldoc; + xmlXPathContextPtr ctxt; + xmlXPathObjectPtr res; + xmlChar *resstr; + xmlXPathCompExprPtr comppath; + + /* Extract the row data as C Strings */ + spi_tuple = tuptable->vals[i]; + pkey = SPI_getvalue(spi_tuple, spi_tupdesc, 1); + xmldoc = SPI_getvalue(spi_tuple, spi_tupdesc, 2); + + /* + * Clear the values array, so that not-well-formed documents + * return NULL in all columns. Note that this also means that + * spare columns will be NULL. + */ + for (j = 0; j < ret_tupdesc->natts; j++) + values[j] = NULL; + + /* Insert primary key */ + values[0] = pkey; + + /* Parse the document */ + if (xmldoc) + doctree = xmlParseMemory(xmldoc, strlen(xmldoc)); + else /* treat NULL as not well-formed */ + doctree = NULL; + + if (doctree == NULL) { - /* Now evaluate the set of xpaths. */ - had_values = false; - for (j = 0; j < numpaths; j++) + /* not well-formed, so output all-NULL tuple */ + ret_tuple = BuildTupleFromCStrings(attinmeta, values); + tuplestore_puttuple(tupstore, ret_tuple); + heap_freetuple(ret_tuple); + } + else + { + /* New loop here - we have to deal with nodeset results */ + rownr = 0; + + do { - ctxt = xmlXPathNewContext(doctree); - ctxt->node = xmlDocGetRootElement(doctree); + /* Now evaluate the set of xpaths. */ + had_values = false; + for (j = 0; j < numpaths; j++) + { + ctxt = xmlXPathNewContext(doctree); + ctxt->node = xmlDocGetRootElement(doctree); - /* compile the path */ - comppath = xmlXPathCompile(xpaths[j]); - if (comppath == NULL) - xml_ereport(xmlerrcxt, ERROR, - ERRCODE_EXTERNAL_ROUTINE_EXCEPTION, - "XPath Syntax Error"); + /* compile the path */ + comppath = xmlXPathCompile(xpaths[j]); + if (comppath == NULL) + xml_ereport(xmlerrcxt, ERROR, + ERRCODE_EXTERNAL_ROUTINE_EXCEPTION, + "XPath Syntax Error"); - /* Now evaluate the path expression. */ - res = xmlXPathCompiledEval(comppath, ctxt); - xmlXPathFreeCompExpr(comppath); + /* Now evaluate the path expression. */ + res = xmlXPathCompiledEval(comppath, ctxt); + xmlXPathFreeCompExpr(comppath); - if (res != NULL) - { - switch (res->type) + if (res != NULL) { - case XPATH_NODESET: - /* We see if this nodeset has enough nodes */ - if (res->nodesetval != NULL && - rownr < res->nodesetval->nodeNr) - { - resstr = xmlXPathCastNodeToString(res->nodesetval->nodeTab[rownr]); - had_values = true; - } - else - resstr = NULL; - - break; - - case XPATH_STRING: - resstr = xmlStrdup(res->stringval); - break; - - default: - elog(NOTICE, "unsupported XQuery result: %d", res->type); - resstr = xmlStrdup((const xmlChar *) "<unsupported/>"); + switch (res->type) + { + case XPATH_NODESET: + /* We see if this nodeset has enough nodes */ + if (res->nodesetval != NULL && + rownr < res->nodesetval->nodeNr) + { + resstr = xmlXPathCastNodeToString(res->nodesetval->nodeTab[rownr]); + had_values = true; + } + else + resstr = NULL; + + break; + + case XPATH_STRING: + resstr = xmlStrdup(res->stringval); + break; + + default: + elog(NOTICE, "unsupported XQuery result: %d", res->type); + resstr = xmlStrdup((const xmlChar *) "<unsupported/>"); + } + + /* + * Insert this into the appropriate column in the + * result tuple. + */ + values[j + 1] = (char *) resstr; } - - /* - * Insert this into the appropriate column in the - * result tuple. - */ - values[j + 1] = (char *) resstr; + xmlXPathFreeContext(ctxt); } - xmlXPathFreeContext(ctxt); - } - /* Now add the tuple to the output, if there is one. */ - if (had_values) - { - ret_tuple = BuildTupleFromCStrings(attinmeta, values); - tuplestore_puttuple(tupstore, ret_tuple); - heap_freetuple(ret_tuple); - } + /* Now add the tuple to the output, if there is one. */ + if (had_values) + { + ret_tuple = BuildTupleFromCStrings(attinmeta, values); + tuplestore_puttuple(tupstore, ret_tuple); + heap_freetuple(ret_tuple); + } - rownr++; - } while (had_values); - } + rownr++; + } while (had_values); + } - if (doctree != NULL) - xmlFreeDoc(doctree); - doctree = NULL; + if (doctree != NULL) + xmlFreeDoc(doctree); + doctree = NULL; - if (pkey) - pfree(pkey); - if (xmldoc) - pfree(xmldoc); - } + if (pkey) + pfree(pkey); + if (xmldoc) + pfree(xmldoc); + } } PG_CATCH(); { diff --git a/contrib/xml2/xslt_proc.c b/contrib/xml2/xslt_proc.c index ba1171a041f..a93931d2618 100644 --- a/contrib/xml2/xslt_proc.c +++ b/contrib/xml2/xslt_proc.c @@ -85,40 +85,40 @@ xslt_process(PG_FUNCTION_ARGS) { /* Check to see if document is a file or a literal */ - if (VARDATA(doct)[0] == '<') - doctree = xmlParseMemory((char *) VARDATA(doct), VARSIZE(doct) - VARHDRSZ); - else - doctree = xmlParseFile(text_to_cstring(doct)); - - if (doctree == NULL) - xml_ereport(xmlerrcxt, ERROR, ERRCODE_EXTERNAL_ROUTINE_EXCEPTION, - "error parsing XML document"); + if (VARDATA(doct)[0] == '<') + doctree = xmlParseMemory((char *) VARDATA(doct), VARSIZE(doct) - VARHDRSZ); + else + doctree = xmlParseFile(text_to_cstring(doct)); - /* Same for stylesheet */ - if (VARDATA(ssheet)[0] == '<') - { - ssdoc = xmlParseMemory((char *) VARDATA(ssheet), - VARSIZE(ssheet) - VARHDRSZ); - if (ssdoc == NULL) + if (doctree == NULL) xml_ereport(xmlerrcxt, ERROR, ERRCODE_EXTERNAL_ROUTINE_EXCEPTION, - "error parsing stylesheet as XML document"); + "error parsing XML document"); - stylesheet = xsltParseStylesheetDoc(ssdoc); - } - else - stylesheet = xsltParseStylesheetFile((xmlChar *) text_to_cstring(ssheet)); + /* Same for stylesheet */ + if (VARDATA(ssheet)[0] == '<') + { + ssdoc = xmlParseMemory((char *) VARDATA(ssheet), + VARSIZE(ssheet) - VARHDRSZ); + if (ssdoc == NULL) + xml_ereport(xmlerrcxt, ERROR, ERRCODE_EXTERNAL_ROUTINE_EXCEPTION, + "error parsing stylesheet as XML document"); + + stylesheet = xsltParseStylesheetDoc(ssdoc); + } + else + stylesheet = xsltParseStylesheetFile((xmlChar *) text_to_cstring(ssheet)); - if (stylesheet == NULL) - xml_ereport(xmlerrcxt, ERROR, ERRCODE_EXTERNAL_ROUTINE_EXCEPTION, - "failed to parse stylesheet"); + if (stylesheet == NULL) + xml_ereport(xmlerrcxt, ERROR, ERRCODE_EXTERNAL_ROUTINE_EXCEPTION, + "failed to parse stylesheet"); - restree = xsltApplyStylesheet(stylesheet, doctree, params); + restree = xsltApplyStylesheet(stylesheet, doctree, params); - if (restree == NULL) - xml_ereport(xmlerrcxt, ERROR, ERRCODE_EXTERNAL_ROUTINE_EXCEPTION, - "failed to apply stylesheet"); + if (restree == NULL) + xml_ereport(xmlerrcxt, ERROR, ERRCODE_EXTERNAL_ROUTINE_EXCEPTION, + "failed to apply stylesheet"); - resstat = xsltSaveResultToString(&resstr, &reslen, restree, stylesheet); + resstat = xsltSaveResultToString(&resstr, &reslen, restree, stylesheet); } PG_CATCH(); { |