The following patch might detect those stylesheet errors. I hope correct
stylesheets are OK with it.
Tom
------------------patch 044-4 begins
Index: error.cpp
===================================================================
RCS file: d:/cvs-master/ga/src/Sablot/engine/error.cpp,v
retrieving revision 1.6
diff -a -u -r1.6 error.cpp
--- error.cpp 2000/09/06 16:42:34 1.6
+++ error.cpp 2000/10/16 21:22:46
@@ -88,6 +88,7 @@
{E_ELEM_MUST_EMPTY, "XSL element '%s' must be empty"},
{E_ELEM_CONT_TEXT_OR_LRE, "XSL element '%s' can only contain XSL
elements"},
{E_ELEM_CONTAINS_ELEM, "XSL element '%s' cannot contain element
'%s' at this point"},
+ {E1_ELEM_TOPLEVEL, "XSL element '%s' can only be used at the top
level"},
{E_BAD_ELEM_CONTENT, "bad element content"},
{ET_BAD_ARGS_N, "wrong number of function arguments"},
{ET_BAD_ARG_TYPE, "illegal argument type"},
Index: error.h
===================================================================
RCS file: d:/cvs-master/ga/src/Sablot/engine/error.h,v
retrieving revision 1.6
diff -a -u -r1.6 error.h
--- error.h 2000/09/06 16:42:34 1.6
+++ error.h 2000/10/16 21:22:51
@@ -164,6 +164,7 @@
E_ELEM_MUST_EMPTY,
E_ELEM_CONT_TEXT_OR_LRE,
E_ELEM_CONTAINS_ELEM,
+ E1_ELEM_TOPLEVEL,
E_BAD_ELEM_CONTENT,
E1_UNSUPPORTED_SCHEME,
E1_URI_OPEN,
Index: parser.cpp
===================================================================
RCS file: d:/cvs-master/ga/src/Sablot/engine/parser.cpp,v
retrieving revision 1.10
diff -a -u -r1.10 parser.cpp
--- parser.cpp 2000/09/06 16:42:34 1.10
+++ parser.cpp 2000/10/16 21:17:20
@@ -313,7 +313,11 @@
};
if (itsXSL)
+ {
toX(v) -> checkAtts();
+ // also check if a toplevel element does not have a
non-stylesheet parent
+ toX(v) -> checkToplevel();
+ }
else
{
if (t -> XSLTree)
Index: verts.cpp
===================================================================
RCS file: d:/cvs-master/ga/src/Sablot/engine/verts.cpp,v
retrieving revision 1.11
diff -a -u -r1.11 verts.cpp
--- verts.cpp 2000/09/06 16:42:34 1.11
+++ verts.cpp 2000/10/16 21:31:58
@@ -1632,6 +1632,16 @@
}
}
+eFlag XSLElement::checkToplevel()
+{
+ if (!(instrTable[op].flags & ELEM_INSTR) &&
+ !(instrTable[op].flags & ELEM_EXTRA) &&
+ (!isXSL(parent) ||
+ !(instrTable[toX(parent) -> op].flags & ELEM_CONT_TOPLEVEL)))
+ Err1(proc -> situation, E1_ELEM_TOPLEVEL, xslOpNames[op]);
+ return OK;
+}
+
eFlag XSLElement::checkChildren()
{
InstrTableItem &iData = instrTable[op];
@@ -1669,6 +1679,7 @@
Err1(proc -> situation, E_BAD_ELEM_CONTENT,
xslOpNames[op]);
}
};
+
proc -> situation->popCurrent();
return OK;
}
Index: verts.h
===================================================================
RCS file: d:/cvs-master/ga/src/Sablot/engine/verts.h,v
retrieving revision 1.6
diff -a -u -r1.6 verts.h
--- verts.h 2000/08/11 15:00:37 1.6
+++ verts.h 2000/10/16 21:23:19
@@ -357,6 +357,7 @@
XSLElement(QName&, Tree *_ownerT, XSL_OP, Processor* proc_);
virtual eFlag execute(Context *c);
virtual eFlag newChild(Vertex*);
+ eFlag checkToplevel();
virtual eFlag checkChildren();
void checkExtraChildren(int& k);
Expression *getAttExpr(XSL_ATT);
------------------patch ends
Petr Cimprich wrote:
>
> The xsl:include element is allowed as a top-level
> element only. It must be used when the XML tree
> for XSLT document is created (parsing the main
> XSLT document and included documents). The bug is
> that Sablotron doesn't complains.
>
> Petr
>
> James Boulton wrote:
> >
> > I think this may be a bug. The following XSL works:
> >
> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > version="1.0">
> > <xsl:output method="html" media-type="text/html" encoding="utf-8"/>
> > <xsl:template match="/products">
> > <div><xsl:include href="file://path.xsl"/></div>
> > </xsl:template>
> > </xsl:stylesheet>
> >
> > But this doesn't...
> >
> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > version="1.0">
> > <xsl:output method="html" media-type="text/html" encoding="utf-8"/>
> > <xsl:template match="/products">
> > <xsl:include href="file://path.xsl"/>
> > </xsl:template>
> > </xsl:stylesheet>
> >
> > The only differnce is the <div> surrounding the include... ??
> >
> > Cheers,
> >
> > --Jim
>
> --
> Petr Cimprich
> Ginger Alliance Ltd.
> www.gingerall.com