1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-08-05 23:35:48 +03:00

fixed bug #60624 improver the error context reporting added a specific

* libxslt/xslt.c: fixed bug #60624
* libxslt/xsltutils.c: improver the error context reporting
* tests/reports/Makefile.am tests/reports/tst-2.*: added a
  specific regression test
* xsltproc/xsltproc: free the stylesheet if it contained an error.
Daniel
This commit is contained in:
Daniel Veillard
2001-09-18 09:56:57 +00:00
parent 2db3204c7d
commit eb5f21553c
9 changed files with 50 additions and 4 deletions

View File

@@ -1,3 +1,11 @@
Tue Sep 18 11:48:20 CEST 2001 Daniel Veillard <daniel@veillard.com>
* libxslt/xslt.c: fixed bug #60624
* libxslt/xsltutils.c: improver the error context reporting
* tests/reports/Makefile.am tests/reports/tst-2.*: added a
specific regression test
* xsltproc/xsltproc: free the stylesheet if it contained an error.
Mon Sep 17 14:45:48 CEST 2001 Daniel Veillard <daniel@veillard.com> Mon Sep 17 14:45:48 CEST 2001 Daniel Veillard <daniel@veillard.com>
* libxslt/variables.c: fixed a problem with global var override * libxslt/variables.c: fixed a problem with global var override

View File

@@ -1693,6 +1693,16 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
cur = cur->next; cur = cur->next;
continue; continue;
} }
if (cur->type == XML_TEXT_NODE) {
if (cur->content != NULL) {
xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"misplaced text element: '%s'\n", cur->content);
}
style->errors++;
cur = cur->next;
continue;
}
if ((cur->type == XML_ELEMENT_NODE) && (cur->ns == NULL)) { if ((cur->type == XML_ELEMENT_NODE) && (cur->ns == NULL)) {
xsltGenericError(xsltGenericErrorContext, xsltGenericError(xsltGenericErrorContext,
"Found a top-level element %s with null namespace URI\n", "Found a top-level element %s with null namespace URI\n",
@@ -1701,7 +1711,7 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
cur = cur->next; cur = cur->next;
continue; continue;
} }
if (!(IS_XSLT_ELEM(cur))) { if ((cur->type == XML_ELEMENT_NODE) && (!(IS_XSLT_ELEM(cur)))) {
xsltTopLevelFunction function; xsltTopLevelFunction function;
function = xsltExtModuleTopLevelLookup(cur->name, function = xsltExtModuleTopLevelLookup(cur->name,

View File

@@ -298,8 +298,17 @@ xsltPrintErrorContext(xsltTransformContextPtr ctxt,
file = doc->URL; file = doc->URL;
} else { } else {
/*
* Try to find contextual informations to report
*/
if (node->type == XML_ELEMENT_NODE) { if (node->type == XML_ELEMENT_NODE) {
line = (int) node->content; line = (int) node->content;
} else if ((node->prev != NULL) &&
(node->prev->type == XML_ELEMENT_NODE)) {
line = (int) node->prev->content;
} else if ((node->parent != NULL) &&
(node->parent->type == XML_ELEMENT_NODE)) {
line = (int) node->parent->content;
} }
if ((node->doc != NULL) && (node->doc->URL != NULL)) if ((node->doc != NULL) && (node->doc->URL != NULL))
file = node->doc->URL; file = node->doc->URL;

View File

@@ -4,7 +4,8 @@ $(top_builddir)/xsltproc/xsltproc:
@(cd ../../xsltproc ; $(MAKE) xsltproc) @(cd ../../xsltproc ; $(MAKE) xsltproc)
EXTRA_DIST = \ EXTRA_DIST = \
tst-1.xml tst-1.xsl tst-1.out tst-1.err tst-1.xml tst-1.xsl tst-1.out tst-1.err \
tst-2.xml tst-2.xsl tst-2.out tst-2.err
all: test all: test
@@ -14,7 +15,7 @@ test tests: $(top_builddir)/xsltproc/xsltproc
@(for i in $(srcdir)/*.xml ; do \ @(for i in $(srcdir)/*.xml ; do \
if [ -d $$i ] ; then continue ; fi ; \ if [ -d $$i ] ; then continue ; fi ; \
doc=`basename $$i .xml` ; \ doc=`basename $$i .xml` ; \
for j in $(srcdir)/$$doc*.xsl ; do \ for j in $(srcdir)/$$doc.xsl ; do \
if [ ! -f $$j ] ; then continue ; fi ; \ if [ ! -f $$j ] ; then continue ; fi ; \
if [ -d $$j ] ; then continue ; fi ; \ if [ -d $$j ] ; then continue ; fi ; \
name=`basename $$j .xsl`; \ name=`basename $$j .xsl`; \

6
tests/reports/tst-2.err Normal file
View File

@@ -0,0 +1,6 @@
compilation error: file ./tst-2.xsl line 2 element text
misplaced text element: '
a not allowed top level element
'

0
tests/reports/tst-2.out Normal file
View File

1
tests/reports/tst-2.xml Normal file
View File

@@ -0,0 +1 @@
<doc/>

10
tests/reports/tst-2.xsl Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
a not allowed top level element
<xsl:template match="/">
</xsl:template>
</xsl:stylesheet>

View File

@@ -618,8 +618,9 @@ main(int argc, char **argv)
} }
xsltProcess(doc, cur, argv[i]); xsltProcess(doc, cur, argv[i]);
} }
xsltFreeStylesheet(cur);
} }
if (cur != NULL)
xsltFreeStylesheet(cur);
done: done:
xsltCleanupGlobals(); xsltCleanupGlobals();
xmlCleanupParser(); xmlCleanupParser();