1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 03:55:04 +03:00

Huge commit: 1.5.0, XML validation, Xpath, bugfixes, examples .... Daniel

This commit is contained in:
Daniel Veillard 1999-08-10 19:04:08 +00:00
parent 6a6ccc1de6
commit b05deb7f5f
95 changed files with 15709 additions and 2561 deletions

View File

@ -1,3 +1,14 @@
Tue Aug 10 20:28:09 CEST 1999 Daniel Veillard <Daniel.Veillard@w3.org>
* configure.in: upgraded to version 1.4.0
* valid.[ch], SAX.c, parser.[ch] parserInternals.h ...
Big update, added a large part of the validation process,
it should be usable, but some parts are missing
* xpath.c: improved the implementation w.r.t. root.
* Makefile.am: added more tests
* test and result trees: added a lot of tests
* libxml.spec.in: export libxml.so.0 and libxml.so.1
Tue Aug 10 11:33:41 CEST 1999 Daniel Veillard <Daniel.Veillard@w3.org>
* Added an HACKING file

View File

@ -515,13 +515,11 @@ htmlEntityDesc html40EntitiesTable[] = {
{ 180, "acute","acute accent = spacing acute, U+00B4 ISOdia" },
{ 181, "micro","micro sign, U+00B5 ISOnum" },
{ 182, "para", "pilcrow sign = paragraph sign, U+00B6 ISOnum" },
{ 183, "middot","middle dot = Georgian comma
= Greek middle dot, U+00B7 ISOnum" },
{ 183, "middot","middle dot = Georgian comma Greek middle dot, U+00B7 ISOnum" },
{ 184, "cedil","cedilla = spacing cedilla, U+00B8 ISOdia" },
{ 185, "sup1", "superscript one = superscript digit one, U+00B9 ISOnum" },
{ 186, "ordm", "masculine ordinal indicator, U+00BA ISOnum" },
{ 187, "raquo","right-pointing double angle quotation mark
= right pointing guillemet, U+00BB ISOnum" },
{ 187, "raquo","right-pointing double angle quotation mark right pointing guillemet, U+00BB ISOnum" },
{ 188, "frac14","vulgar fraction one quarter = fraction one quarter, U+00BC ISOnum" },
{ 189, "frac12","vulgar fraction one half = fraction one half, U+00BD ISOnum" },
{ 190, "frac34","vulgar fraction three quarters = fraction three quarters, U+00BE ISOnum" },
@ -550,7 +548,7 @@ htmlEntityDesc html40EntitiesTable[] = {
{ 213, "Otilde","latin capital letter O with tilde, U+00D5 ISOlat1" },
{ 214, "Ouml", "latin capital letter O with diaeresis, U+00D6 ISOlat1" },
{ 215, "times","multiplication sign, U+00D7 ISOnum" },
{ 216, "Oslash","latin capital letter O with stroke = latin capital letter O slash, U+00D8 ISOlat1" },
{ 216, "Oslash","latin capital letter O with stroke latin capital letter O slash, U+00D8 ISOlat1" },
{ 217, "Ugrave","latin capital letter U with grave, U+00D9 ISOlat1" },
{ 218, "Uacute","latin capital letter U with acute, U+00DA ISOlat1" },
{ 219, "Ucirc","latin capital letter U with circumflex, U+00DB ISOlat1" },
@ -657,8 +655,7 @@ htmlEntityDesc html40EntitiesTable[] = {
{ 8254, "oline","overline = spacing overscore, U+203E NEW" },
{ 8260, "frasl","fraction slash, U+2044 NEW" },
{ 8472, "weierp","script capital P = power set
= Weierstrass p, U+2118 ISOamso" },
{ 8472, "weierp","script capital P = power set = Weierstrass p, U+2118 ISOamso" },
{ 8465, "image","blackletter capital I = imaginary part, U+2111 ISOamso" },
{ 8476, "real", "blackletter capital R = real part symbol, U+211C ISOamso" },
{ 8482, "trade","trade mark sign, U+2122 ISOnum" },
@ -754,8 +751,7 @@ htmlEntityDesc html40EntitiesTable[] = {
{ 8225, "Dagger","double dagger, U+2021 ISOpub" },
{ 8240, "permil","per mille sign, U+2030 ISOtech" },
{ 8249, "lsaquo","single left-pointing angle quotation mark, U+2039 ISO proposed" },
{ 8250, "rsaquo","single right-pointing angle quotation mark,
U+203A ISO proposed" },
{ 8250, "rsaquo","single right-pointing angle quotation mark, U+203A ISO proposed" },
{ 8364, "euro", "euro sign, U+20AC NEW" }
};

View File

@ -44,7 +44,7 @@ xmlinc_HEADERS = \
valid.h
DEPS = $(top_builddir)/libxml.la
LDADDS = $(top_builddir)/libxml.la @Z_LIBS@
LDADDS = $(top_builddir)/libxml.la @Z_LIBS@ @M_LIBS@
tester_SOURCES=tester.c
tester_LDFLAGS =
@ -68,108 +68,167 @@ testXPath_LDADD= $(LDADDS)
check-local: tests
testall : tests SVGtests SAXtests XPathtests
testall : tests SVGtests SAXtests XPathtests XMLenttests
tests: XMLtests HTMLtests Validtests
tests: HTMLtests XMLtests
HTMLtests : testHTML
@(DIR=`pwd`; cd $(srcdir) ; \
for i in test/HTML/* ; do \
@echo "##"
@echo "## HTML regression tests"
@echo "##"
@(for i in $(srcdir)/test/HTML/* ; do \
name=`basename $$i`; \
if [ ! -d $$i ] ; then \
if [ ! -f result/HTML/`basename $$i` ] ; then \
echo New test file `basename $$i` ; \
$$DIR/testHTML $$i > result/HTML/`basename $$i` ; \
if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \
echo New test file $$name ; \
testHTML $$i > $(srcdir)/result/HTML/$$name ; \
else \
echo Testing `basename $$i` ; \
$$DIR/testHTML $$i > result.`basename $$i` ; \
diff result/HTML/`basename $$i` result.`basename $$i` ; \
$$DIR/testHTML result.`basename $$i` > result2.`basename $$i` ; \
diff result.`basename $$i` result2.`basename $$i` ; \
rm result.`basename $$i` result2.`basename $$i` ; \
echo Testing $$name ; \
testHTML $$i > result.$$name ; \
diff $(srcdir)/result/HTML/$$name result.$$name ; \
testHTML result.$$name > result2.$$name ; \
diff result.$$name result2.$$name ; \
rm result.$$name result2.$$name ; \
fi ; fi ; done)
XMLtests : tester
@(DIR=`pwd`; cd $(srcdir) ; \
for i in test/* ; do \
@echo "##"
@echo "## XML regression tests"
@echo "##"
@(for i in $(srcdir)/test/* ; do \
name=`basename $$i`; \
if [ ! -d $$i ] ; then \
if [ ! -f result/`basename $$i` ] ; then \
echo New test file `basename $$i` ; \
$$DIR/tester $$i > result/`basename $$i` ; \
if [ ! -f $(srcdir)/result/$$name ] ; then \
echo New test file $$name ; \
tester $$i > $(srcdir)/result/$$name ; \
else \
echo Testing `basename $$i` ; \
$$DIR/tester $$i > result.`basename $$i` ; \
diff result/`basename $$i` result.`basename $$i` ; \
$$DIR/tester result.`basename $$i` > result2.`basename $$i` ; \
diff result.`basename $$i` result2.`basename $$i` ; \
rm result.`basename $$i` result2.`basename $$i` ; \
echo Testing $$name ; \
tester $$i > result.$$name ; \
diff $(srcdir)/result/$$name result.$$name ; \
tester result.$$name > result2.$$name ; \
diff result.$$name result2.$$name ; \
rm result.$$name result2.$$name ; \
fi ; fi ; done)
SVGtests : tester
@(DIR=`pwd`; cd $(srcdir) ; \
for i in test/SVG/* ; do \
XMLenttests : tester
@echo "##"
@echo "## XML entity subst regression tests"
@echo "##"
@(for i in $(srcdir)/test/* ; do \
name=`basename $$i`; \
if [ ! -d $$i ] ; then \
if [ ! -f result/SVG/`basename $$i` ] ; then \
echo New test file `basename $$i` ; \
$$DIR/tester $$i > result/SVG/`basename $$i` ; \
if [ ! -f $(srcdir)/result/noent/$$name ] ; then \
echo New test file $$name ; \
tester --noent $$i > $(srcdir)/result/noent/$$name ; \
else \
echo Testing `basename $$i` ; \
$$DIR/tester $$i > result.`basename $$i` ; \
diff result/SVG/`basename $$i` result.`basename $$i` ; \
$$DIR/tester result.`basename $$i` > result2.`basename $$i` ; \
diff result.`basename $$i` result2.`basename $$i` ; \
rm result.`basename $$i` result2.`basename $$i` ; \
echo Testing $$name ; \
tester --noent $$i > result.$$name ; \
diff $(srcdir)/result/noent/$$name result.$$name ; \
tester --noent result.$$name > result2.$$name ; \
diff result.$$name result2.$$name ; \
rm result.$$name result2.$$name ; \
fi ; fi ; done)
XPathtests : testXPath
@(DIR=`pwd`; cd $(srcdir) ; \
for i in test/XPath/expr/* ; do \
if [ ! -d $$i ] ; then \
if [ ! -f result/XPath/expr/`basename $$i` ] ; then \
echo New test file `basename $$i` ; \
$$DIR/testXPath -f --expr $$i > result/XPath/expr/`basename $$i` ; \
else \
echo Testing `basename $$i` ; \
$$DIR/testXPath -f --expr $$i > result.`basename $$i` ; \
diff result/XPath/expr/`basename $$i` result.`basename $$i` ; \
rm result.`basename $$i` ; \
fi ; fi ; done)
@(DIR=`pwd`; cd $(srcdir) ; \
for i in test/XPath/docs/* ; do \
if [ ! -d $$i ] ; then \
@echo "##"
@echo "## XPath regression tests"
@echo "##"
@(for i in $(srcdir)/test/XPath/expr/* ; do \
name=`basename $$i`; \
for j in test/XPath/tests/$$name* ; do \
if [ ! -d $$j ] ; then \
if [ ! -f result/XPath/tests/`basename $$j` ] ; then \
echo New test file `basename $$i` ; \
$$DIR/testXPath -f -i $$i $$j > result/XPath/tests/`basename $$j` ; \
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/result/XPath/expr/$$name ] ; then \
echo New test file $$name ; \
testXPath -f --expr $$i > $(srcdir)/result/XPath/expr/$$name ; \
else \
echo Testing `basename $$j` ; \
$$DIR/testXPath -f -i $$i $$j > result.`basename $$j` ; \
diff result/XPath/tests/`basename $$j` result.`basename $$j` ; \
rm result.`basename $$j` ; \
echo Testing $$name ; \
testXPath -f --expr $$i > result.$$name ; \
diff $(srcdir)/result/XPath/expr/$$name result.$$name ; \
rm result.$$name ; \
fi ; fi ; done)
@(for i in $(srcdir)/test/XPath/docs/* ; do \
if [ ! -d $$i ] ; then \
doc=`basename $$i`; \
for j in $(srcdir)/test/XPath/tests/$$doc* ; do \
name=`basename $$j`; \
if [ ! -d $$j ] ; then \
if [ ! -f $(srcdir)/result/XPath/tests/$$name ] ; then \
echo New test file $$name ; \
testXPath -f -i $$i $$j > $(srcdir)/result/XPath/tests/$$name ; \
else \
echo Testing $$name ; \
testXPath -f -i $$i $$j > result.$$name ; \
diff $(srcdir)/result/XPath/tests/$$name result.$$name ; \
rm result.$$name ; \
fi ; fi ; done ; fi ; done)
SAXtests : testSAX
@(DIR=`pwd`; cd $(srcdir) ; \
for i in test/* ; do \
SVGtests : tester
@echo "##"
@echo "## SVG parsing regression tests"
@echo "##"
@(for i in $(srcdir)/test/SVG/* ; do \
name=`basename $$i`; \
if [ ! -d $$i ] ; then \
if [ ! -f SAXresult/`basename $$i` ] ; then \
echo New test file `basename $$i` ; \
$$DIR/testSAX $$i > SAXresult/`basename $$i` ; \
if [ ! -f $(srcdir)/result/SVG/$$name ] ; then \
echo New test file $$name ; \
tester $$i > $(srcdir)/result/SVG/$$name ; \
else \
echo Testing `basename $$i` ; \
$$DIR/testSAX $$i > result.`basename $$i` ; \
diff SAXresult/`basename $$i` result.`basename $$i` ; \
rm result.`basename $$i` ; \
echo Testing $$name ; \
tester $$i > result.$$name ; \
diff $(srcdir)/result/SVG/$$name result.$$name ; \
tester result.$$name > result2.$$name ; \
diff result.$$name result2.$$name ; \
rm result.$$name result2.$$name ; \
fi ; fi ; done)
## Put `exec' in the name because this should be installed by
## `install-exec', not `install-data'.
SAXtests : testSAX
@echo "##"
@echo "## SAX callbacks regression tests"
@echo "##"
@(for i in $(srcdir)/test/* ; do \
name=`basename $$i`; \
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/SAXresult/$$name ] ; then \
echo New test file $$name ; \
testSAX $$i > $(srcdir)/SAXresult/$$name ; \
else \
echo Testing $$name ; \
testSAX $$i > result.$$name ; \
diff $(srcdir)/SAXresult/$$name result.$$name ; \
rm result.$$name ; \
fi ; fi ; done)
confexecdir=$(libdir)
confexec_DATA = xmlConf.sh
EXTRA_DIST = xmlConf.sh.in libxml.spec.in test result SAXresult example/Makefile.am \
example/gjobread.c example/gjobs.xml
Validtests : tester
@echo "##"
@echo "## Validity checking regression tests"
@echo "##"
@(for i in $(srcdir)/test/VC/* ; do \
name=`basename $$i`; \
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/result/VC/$$name ] ; then \
echo New test file $$name ; \
tester --noout --valid $$i 2> $(srcdir)/result/VC/$$name ; \
else \
echo Testing $$name ; \
tester --noout --valid $$i 2> result.$$name ; \
diff $(srcdir)/result/VC/$$name result.$$name ; \
rm result.$$name ; \
fi ; fi ; done)
@echo "##"
@echo "## Valid documents regression tests"
@echo "##"
@(for i in $(srcdir)/test/valid/* ; do \
name=`basename $$i`; \
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/result/valid/$$name ] ; then \
echo New test file $$name ; \
tester --valid $$i > $(srcdir)/result/valid/$$name ; \
else \
echo Testing $$name ; \
tester --valid $$i > result.$$name ; \
diff $(srcdir)/result/valid/$$name result.$$name ; \
rm result.$$name ; \
fi ; fi ; done)
dist-hook:
cp libxml.spec $(distdir)

162
SAX.c
View File

@ -132,7 +132,7 @@ hasExternalSubset(void *ctx)
}
/**
* hasInternalSubset:
* internalSubset:
* @ctx: the user data (XML parser context)
*
* Does this document has an internal subset
@ -141,15 +141,72 @@ void
internalSubset(void *ctx, const CHAR *name,
const CHAR *ExternalID, const CHAR *SystemID)
{
xmlDtdPtr externalSubset;
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
#ifdef DEBUG_SAX
fprintf(stderr, "SAX.internalSubset(%s, %s, %s)\n",
name, ExternalID, SystemID);
#endif
xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID);
if ((ExternalID != NULL) || (SystemID != NULL)) {
externalSubset = xmlParseDTD(ExternalID, SystemID);
if (((ExternalID != NULL) || (SystemID != NULL)) &&
(ctxt->validate && ctxt->wellFormed && ctxt->myDoc)) {
/*
* Try to fetch and parse the external subset.
*/
xmlDtdPtr ret = NULL;
xmlParserCtxtPtr dtdCtxt;
xmlParserInputPtr input = NULL;
xmlCharEncoding enc;
dtdCtxt = xmlNewParserCtxt();
if (dtdCtxt == NULL) return;
/*
* Ask the Entity resolver to load the damn thing
*/
if ((ctxt->directory != NULL) && (dtdCtxt->directory == NULL))
dtdCtxt->directory = xmlStrdup(ctxt->directory);
if ((dtdCtxt->sax != NULL) && (dtdCtxt->sax->resolveEntity != NULL))
input = dtdCtxt->sax->resolveEntity(dtdCtxt->userData, ExternalID,
SystemID);
if (input == NULL) {
xmlFreeParserCtxt(dtdCtxt);
return;
}
/*
* plug some encoding conversion routines here. !!!
*/
xmlPushInput(dtdCtxt, input);
enc = xmlDetectCharEncoding(dtdCtxt->input->cur);
xmlSwitchEncoding(dtdCtxt, enc);
if (input->filename == NULL)
input->filename = xmlStrdup(SystemID);
input->line = 1;
input->col = 1;
input->base = dtdCtxt->input->cur;
input->cur = dtdCtxt->input->cur;
input->free = NULL;
/*
* let's parse that entity knowing it's an external subset.
*/
xmlParseExternalSubset(dtdCtxt, ExternalID, SystemID);
if (dtdCtxt->myDoc != NULL) {
if (dtdCtxt->wellFormed) {
ret = dtdCtxt->myDoc->intSubset;
dtdCtxt->myDoc->intSubset = NULL;
} else {
ret = NULL;
}
xmlFreeDoc(dtdCtxt->myDoc);
dtdCtxt->myDoc = NULL;
}
xmlFreeParserCtxt(dtdCtxt);
ctxt->myDoc->extSubset = ret;
}
}
@ -214,6 +271,29 @@ getEntity(void *ctx, const CHAR *name)
return(ret);
}
/**
* getParameterEntity:
* @ctx: the user data (XML parser context)
* @name: The entity name
*
* Get a parameter entity by name
*
* Returns the xmlEntityPtr if found.
*/
xmlEntityPtr
getParameterEntity(void *ctx, const CHAR *name)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlEntityPtr ret;
#ifdef DEBUG_SAX
fprintf(stderr, "SAX.getParameterEntity(%s)\n", name);
#endif
ret = xmlGetParameterEntity(ctxt->myDoc, name);
return(ret);
}
/**
* entityDecl:
@ -256,13 +336,19 @@ attributeDecl(void *ctx, const CHAR *elem, const CHAR *name,
xmlEnumerationPtr tree)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlAttributePtr attr;
#ifdef DEBUG_SAX
fprintf(stderr, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",
elem, name, type, def, defaultValue);
#endif
xmlAddAttributeDecl(ctxt->myDoc->intSubset, elem, name, type, def,
defaultValue, tree);
attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, elem,
name, type, def, defaultValue, tree);
if (attr == 0) ctxt->valid = 0;
if (ctxt->validate && ctxt->wellFormed &&
ctxt->myDoc && ctxt->myDoc->intSubset)
ctxt->valid &= xmlValidateAttributeDecl(&ctxt->vctxt, ctxt->myDoc,
attr);
}
/**
@ -281,12 +367,19 @@ elementDecl(void *ctx, const CHAR *name, int type,
xmlElementContentPtr content)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlElementPtr elem;
#ifdef DEBUG_SAX
fprintf(stderr, "SAX.elementDecl(%s, %d, ...)\n",
name, type);
#endif
xmlAddElementDecl(ctxt->myDoc->intSubset, name, type, content);
elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->intSubset,
name, type, content);
if (elem == 0) ctxt->valid = 0;
if (ctxt->validate && ctxt->wellFormed &&
ctxt->myDoc && ctxt->myDoc->intSubset)
ctxt->valid &= xmlValidateElementDecl(&ctxt->vctxt, ctxt->myDoc, elem);
}
/**
@ -304,10 +397,19 @@ notationDecl(void *ctx, const CHAR *name,
const CHAR *publicId, const CHAR *systemId)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlNotationPtr nota;
#ifdef DEBUG_SAX
fprintf(stderr, "SAX.notationDecl(%s, %s, %s)\n", name, publicId, systemId);
#endif
xmlAddNotationDecl(ctxt->myDoc->intSubset, name, publicId, systemId);
nota = xmlAddNotationDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, name,
publicId, systemId);
if (nota == 0) ctxt->valid = 0;
if (ctxt->validate && ctxt->wellFormed &&
ctxt->myDoc && ctxt->myDoc->intSubset)
ctxt->valid &= xmlValidateNotationDecl(&ctxt->vctxt, ctxt->myDoc,
nota);
}
/**
@ -442,8 +544,15 @@ attribute(void *ctx, const CHAR *fullname, const CHAR *value)
}
ret = xmlNewProp(ctxt->node, name, NULL);
if ((ret != NULL) && (ctxt->replaceEntities == 0))
ret->val = xmlStringGetNodeList(ctxt->myDoc, value);
if (ctxt->validate && ctxt->wellFormed &&
ctxt->myDoc && ctxt->myDoc->intSubset)
ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc,
ctxt->node, ret, value);
if (name != NULL)
free(name);
if (ns != NULL)
@ -569,6 +678,12 @@ endElement(void *ctx, const CHAR *name)
xmlParserAddNodeInfo(ctxt, &node_info);
}
if (ctxt->validate && ctxt->wellFormed &&
ctxt->myDoc && ctxt->myDoc->intSubset)
ctxt->valid &= xmlValidateOneElement(&ctxt->vctxt, ctxt->myDoc,
cur);
/*
* end of parsing of this node.
*/
@ -821,6 +936,29 @@ comment(void *ctx, const CHAR *value)
#endif
ret = xmlNewDocComment(ctxt->myDoc, value);
xmlAddChild(ctxt->node, ret);
/* !!!!! merges */
}
/**
* cdataBlock:
* @ctx: the user data (XML parser context)
* @value: The pcdata content
* @len: the block length
*
* called when a pcdata block has been parsed
*/
void
cdataBlock(void *ctx, const CHAR *value, int len)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlNodePtr ret;
#ifdef DEBUG_SAX
fprintf(stderr, "SAX.pcdata(%s, %d)\n", name, len);
#endif
ret = xmlNewCDataBlock(ctxt->myDoc, value, len);
xmlAddChild(ctxt->node, ret);
/* !!!!! merges */
}
/*
@ -851,6 +989,8 @@ xmlSAXHandler xmlDefaultSAXHandler = {
xmlParserWarning,
xmlParserError,
xmlParserError,
getParameterEntity,
cdataBlock,
};
/**
@ -867,6 +1007,7 @@ xmlDefaultSAXHandlerInit(void)
xmlDefaultSAXHandler.hasExternalSubset = hasExternalSubset;
xmlDefaultSAXHandler.resolveEntity = resolveEntity;
xmlDefaultSAXHandler.getEntity = getEntity;
xmlDefaultSAXHandler.getParameterEntity = getParameterEntity;
xmlDefaultSAXHandler.entityDecl = entityDecl;
xmlDefaultSAXHandler.attributeDecl = attributeDecl;
xmlDefaultSAXHandler.elementDecl = elementDecl;
@ -879,6 +1020,7 @@ xmlDefaultSAXHandlerInit(void)
xmlDefaultSAXHandler.endElement = endElement;
xmlDefaultSAXHandler.reference = reference;
xmlDefaultSAXHandler.characters = characters;
xmlDefaultSAXHandler.cdataBlock = cdataBlock;
xmlDefaultSAXHandler.ignorableWhitespace = ignorableWhitespace;
xmlDefaultSAXHandler.processingInstruction = processingInstruction;
xmlDefaultSAXHandler.comment = comment;
@ -915,6 +1057,8 @@ xmlSAXHandler htmlDefaultSAXHandler = {
xmlParserWarning,
xmlParserError,
xmlParserError,
getParameterEntity,
NULL,
};
/**
@ -931,6 +1075,7 @@ htmlDefaultSAXHandlerInit(void)
htmlDefaultSAXHandler.hasExternalSubset = NULL;
htmlDefaultSAXHandler.resolveEntity = NULL;
htmlDefaultSAXHandler.getEntity = getEntity;
htmlDefaultSAXHandler.getParameterEntity = NULL;
htmlDefaultSAXHandler.entityDecl = NULL;
htmlDefaultSAXHandler.attributeDecl = NULL;
htmlDefaultSAXHandler.elementDecl = NULL;
@ -943,6 +1088,7 @@ htmlDefaultSAXHandlerInit(void)
htmlDefaultSAXHandler.endElement = endElement;
htmlDefaultSAXHandler.reference = NULL;
htmlDefaultSAXHandler.characters = characters;
htmlDefaultSAXHandler.cdataBlock = NULL;
htmlDefaultSAXHandler.ignorableWhitespace = ignorableWhitespace;
htmlDefaultSAXHandler.processingInstruction = NULL;
htmlDefaultSAXHandler.comment = comment;

2
TODO
View File

@ -1,6 +1,8 @@
TODO for the XML parser:
- use libunicode !
- finish XPath, then XPointer, Xlink
- Support for UTF-8 and UTF-16 encoding (Urgent !!!).
- progressive parsing. The entity support is a first step toward
asbtraction of an input stream. A large part of the context is still

View File

@ -1,3 +1,6 @@
#undef PACKAGE
#undef VERSION
#undef HAVE_LIBZ
#undef HAVE_LIBM
#undef HAVE_ISINF
#undef HAVE_ISNAN

View File

@ -9,6 +9,30 @@
#undef PACKAGE
#undef VERSION
#undef HAVE_LIBZ
#undef HAVE_LIBM
#undef HAVE_ISINF
#undef HAVE_ISNAN
/* Define if you have the class function. */
#undef HAVE_CLASS
/* Define if you have the finite function. */
#undef HAVE_FINITE
/* Define if you have the fp_class function. */
#undef HAVE_FP_CLASS
/* Define if you have the fpclass function. */
#undef HAVE_FPCLASS
/* Define if you have the isinf function. */
#undef HAVE_ISINF
/* Define if you have the isnan function. */
#undef HAVE_ISNAN
/* Define if you have the isnand function. */
#undef HAVE_ISNAND
/* Define if you have the snprintf function. */
#undef HAVE_SNPRINTF
@ -34,9 +58,24 @@
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define if you have the <float.h> header file. */
#undef HAVE_FLOAT_H
/* Define if you have the <fp_class.h> header file. */
#undef HAVE_FP_CLASS_H
/* Define if you have the <ieeefp.h> header file. */
#undef HAVE_IEEEFP_H
/* Define if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define if you have the <math.h> header file. */
#undef HAVE_MATH_H
/* Define if you have the <nan.h> header file. */
#undef HAVE_NAN_H
/* Define if you have the <ndir.h> header file. */
#undef HAVE_NDIR_H

View File

@ -4,7 +4,7 @@ AC_INIT(entities.h)
AM_CONFIG_HEADER(config.h)
LIBXML_MAJOR_VERSION=1
LIBXML_MINOR_VERSION=4
LIBXML_MINOR_VERSION=5
LIBXML_MICRO_VERSION=0
LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION
LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION
@ -39,11 +39,13 @@ AC_CHECK_LIB(z, inflate,
AC_CHECK_HEADER(zlib.h,
Z_LIBS="-lz"; AC_DEFINE(HAVE_LIBZ)))
dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h unistd.h ctype.h dirent.h errno.h malloc.h)
AC_CHECK_HEADERS(stdarg.h sys/stat.h sys/types.h time.h zlib.h)
AC_CHECK_HEADERS(ieeefp.h nan.h math.h fp_class.h float.h)
dnl Specific dir for HTML output ?
if test "x$with_html_dir" = "x" ; then
@ -54,15 +56,6 @@ fi
AC_SUBST(HTML_DIR)
XML_LIBDIR='-L${libdir}'
XML_INCLUDEDIR='-I${includedir}/gnome-xml'
XML_LIBS="-lxml $Z_LIBS"
AC_SUBST(XML_LIBDIR)
AC_SUBST(XML_LIBS)
AC_SUBST(XML_INCLUDEDIR)
AC_SUBST(HTML_DIR)
AC_ARG_ENABLE(corba, [ --enable-corba Add Corba support (default)])
dnl
@ -75,7 +68,41 @@ AC_SUBST(CORBA_CFLAGS)
dnl Checks for library functions.
AC_FUNC_STRFTIME
AC_CHECK_FUNCS(strdup strndup strerror snprintf )
AC_CHECK_FUNCS(strdup strndup strerror snprintf)
AC_CHECK_FUNCS(finite isinf isnan isnand fp_class class fpclass finite)
dnl Checks for isnan in libm if not in libc
M_LIBS=
if test "$ac_cv_func_isnan" != "yes"
then
AC_CHECK_LIB(m, isnan,
M_LIBS="-lm"; AC_DEFINE(HAVE_ISNAN))
fi
dnl Checks for isinf in libm if not in libc
if test "$ac_cv_func_isinf" != "yes"
then
M2_LIBS=""
AC_CHECK_LIB(m, isinf,
M2_LIBS="-lm"; AC_DEFINE(HAVE_ISINF))
if test "$M2_LIBS" != ""
then
M_LIBS="$M2_LIBS"
fi
fi
XML_LIBDIR='-L${libdir}'
XML_INCLUDEDIR='-I${includedir}/gnome-xml'
XML_LIBS="-lxml $Z_LIBS $M_LIBS"
AC_SUBST(XML_LIBDIR)
AC_SUBST(XML_LIBS)
AC_SUBST(XML_INCLUDEDIR)
AC_SUBST(HTML_DIR)
AC_SUBST(HAVE_ISNAN)
AC_SUBST(HAVE_ISINF)
AC_SUBST(Z_LIBS)
AC_SUBST(M_LIBS)
AC_OUTPUT(libxml.spec Makefile doc/Makefile example/Makefile xml-config)

View File

@ -115,7 +115,7 @@ SIZE="3"
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN3699"
NAME="AEN3763"
></A
><H2
>Name</H2
@ -123,7 +123,7 @@ NAME="AEN3699"
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN3702"
NAME="AEN3766"
></A
><H2
>Synopsis</H2
@ -260,6 +260,20 @@ HREF="gnome-xml-tree.html#XMLDOCPTR"
HREF="gnome-xml-tree.html#CHAR"
>CHAR</A
> *name);
<A
HREF="gnome-xml-entities.html#XMLENTITYPTR"
>xmlEntityPtr</A
> <A
HREF="gnome-xml-entities.html#XMLGETPARAMETERENTITY"
>xmlGetParameterEntity</A
> (<A
HREF="gnome-xml-tree.html#XMLDOCPTR"
>xmlDocPtr</A
> doc,
const <A
HREF="gnome-xml-tree.html#CHAR"
>CHAR</A
> *name);
const <A
HREF="gnome-xml-tree.html#CHAR"
>CHAR</A
@ -330,7 +344,7 @@ HREF="gnome-xml-entities.html#XMLENTITIESTABLEPTR"
><DIV
CLASS="REFSECT1"
><A
NAME="AEN3755"
NAME="AEN3823"
></A
><H2
>Description</H2
@ -340,14 +354,14 @@ NAME="AEN3755"
><DIV
CLASS="REFSECT1"
><A
NAME="AEN3758"
NAME="AEN3826"
></A
><H2
>Details</H2
><DIV
CLASS="REFSECT2"
><A
NAME="AEN3760"
NAME="AEN3828"
></A
><H3
><A
@ -363,7 +377,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XML_INTERNAL_GENERAL_ENTITY 1</PRE
>#define XML_INTERNAL_GENERAL_ENTITY</PRE
></TD
></TR
></TABLE
@ -373,7 +387,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN3765"
NAME="AEN3833"
></A
><H3
><A
@ -389,7 +403,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XML_EXTERNAL_GENERAL_PARSED_ENTITY 2</PRE
>#define XML_EXTERNAL_GENERAL_PARSED_ENTITY</PRE
></TD
></TR
></TABLE
@ -399,7 +413,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN3770"
NAME="AEN3838"
></A
><H3
><A
@ -415,7 +429,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XML_EXTERNAL_GENERAL_UNPARSED_ENTITY 3</PRE
>#define XML_EXTERNAL_GENERAL_UNPARSED_ENTITY</PRE
></TD
></TR
></TABLE
@ -425,7 +439,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN3775"
NAME="AEN3843"
></A
><H3
><A
@ -441,7 +455,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XML_INTERNAL_PARAMETER_ENTITY 4</PRE
>#define XML_INTERNAL_PARAMETER_ENTITY</PRE
></TD
></TR
></TABLE
@ -451,7 +465,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN3780"
NAME="AEN3848"
></A
><H3
><A
@ -467,7 +481,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XML_EXTERNAL_PARAMETER_ENTITY 5</PRE
>#define XML_EXTERNAL_PARAMETER_ENTITY</PRE
></TD
></TR
></TABLE
@ -477,7 +491,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN3785"
NAME="AEN3853"
></A
><H3
><A
@ -493,7 +507,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XML_INTERNAL_PREDEFINED_ENTITY 6</PRE
>#define XML_INTERNAL_PREDEFINED_ENTITY</PRE
></TD
></TR
></TABLE
@ -503,33 +517,20 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN3790"
NAME="AEN3858"
></A
><H3
><A
NAME="XMLENTITYPTR"
></A
>xmlEntityPtr</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef xmlEntity *xmlEntityPtr;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN3795"
NAME="AEN3862"
></A
><H3
><A
@ -545,7 +546,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XML_MIN_ENTITIES_TABLE 32</PRE
>#define XML_MIN_ENTITIES_TABLE</PRE
></TD
></TR
></TABLE
@ -555,33 +556,20 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN3800"
NAME="AEN3867"
></A
><H3
><A
NAME="XMLENTITIESTABLEPTR"
></A
>xmlEntitiesTablePtr</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef xmlEntitiesTable *xmlEntitiesTablePtr;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN3805"
NAME="AEN3871"
></A
><H3
><A
@ -651,7 +639,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the document</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -668,7 +656,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the entity name</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -685,7 +673,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the entity type XML_xxx_yyy_ENTITY</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -702,7 +690,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the entity external ID if available</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -719,7 +707,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the entity system ID if available</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -736,7 +724,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the entity content</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -746,7 +734,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN3845"
NAME="AEN3911"
></A
><H3
><A
@ -816,7 +804,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the document</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -833,7 +821,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the entity name</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -850,7 +838,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the entity type XML_xxx_yyy_ENTITY</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -867,7 +855,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the entity external ID if available</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -884,7 +872,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the entity system ID if available</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -901,7 +889,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the entity content</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -911,7 +899,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN3885"
NAME="AEN3951"
></A
><H3
><A
@ -967,7 +955,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the entity name</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -982,7 +970,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>NULL if not, othervise the entity</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -992,7 +980,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN3906"
NAME="AEN3972"
></A
><H3
><A
@ -1054,7 +1042,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the document referencing the entity</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1071,7 +1059,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the entity name</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1086,7 +1074,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>A pointer to the entity structure or NULL if not found.</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -1096,7 +1084,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN3932"
NAME="AEN3998"
></A
><H3
><A
@ -1157,7 +1145,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the document referencing the entity</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1174,7 +1162,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the entity name</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1189,7 +1177,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>A pointer to the entity structure or NULL if not found.</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -1199,7 +1187,110 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN3958"
NAME="AEN4024"
></A
><H3
><A
NAME="XMLGETPARAMETERENTITY"
></A
>xmlGetParameterEntity ()</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
><A
HREF="gnome-xml-entities.html#XMLENTITYPTR"
>xmlEntityPtr</A
> xmlGetParameterEntity (<A
HREF="gnome-xml-tree.html#XMLDOCPTR"
>xmlDocPtr</A
> doc,
const <A
HREF="gnome-xml-tree.html#CHAR"
>CHAR</A
> *name);</PRE
></TD
></TR
></TABLE
><P
>Do an entity lookup in the internal and external subsets and
returns the corresponding parameter entity, if found.</P
><P
></P
><DIV
CLASS="INFORMALTABLE"
><P
></P
><TABLE
BORDER="0"
WIDTH="100%"
BGCOLOR="#FFD0D0"
CELLSPACING="0"
CELLPADDING="4"
CLASS="CALSTABLE"
><TR
><TD
WIDTH="20%"
ALIGN="RIGHT"
VALIGN="TOP"
><TT
CLASS="PARAMETER"
><I
>doc</I
></TT
>&nbsp;:</TD
><TD
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>&nbsp;</TD
></TR
><TR
><TD
WIDTH="20%"
ALIGN="RIGHT"
VALIGN="TOP"
><TT
CLASS="PARAMETER"
><I
>name</I
></TT
>&nbsp;:</TD
><TD
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>&nbsp;</TD
></TR
><TR
><TD
WIDTH="20%"
ALIGN="RIGHT"
VALIGN="TOP"
><I
CLASS="EMPHASIS"
>Returns</I
> :</TD
><TD
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>&nbsp;</TD
></TR
></TABLE
><P
></P
></DIV
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN4050"
></A
><H3
><A
@ -1233,13 +1324,10 @@ HREF="gnome-xml-tree.html#CHAR"
>Do a global encoding of a string, replacing the predefined entities
and non ASCII values with their entities and CharRef counterparts.</P
><P
>TODO !!!! Once moved to UTF-8 internal encoding, the encoding of non-ascii
get erroneous.</P
>TODO: remove this, once we are not afraid of breaking binary compatibility</P
><P
>TODO This routine is not reentrant, the interface
should not be modified though.</P
><P
>People must migrate their code to xmlEncodeEntitiesReentrant !</P
>People must migrate their code to xmlEncodeEntitiesReentrant !
This routine will issue a warning when encountered.</P
><P
></P
><DIV
@ -1268,7 +1356,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the document containing the string</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1285,7 +1373,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> A string to convert to XML.</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1300,7 +1388,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>A newly allocated string with the substitution done.</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -1310,7 +1398,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN3987"
NAME="AEN4078"
></A
><H3
><A
@ -1376,7 +1464,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the document containing the string</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1393,7 +1481,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> A string to convert to XML.</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1408,7 +1496,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>A newly allocated string with the substitution done.</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -1418,7 +1506,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN4014"
NAME="AEN4105"
></A
><H3
><A
@ -1469,7 +1557,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>the xmlEntitiesTablePtr just created or NULL in case of error.</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -1479,7 +1567,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN4030"
NAME="AEN4121"
></A
><H3
><A
@ -1535,7 +1623,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> An entity table</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1550,7 +1638,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>the new xmlEntitiesTablePtr or NULL in case of error.</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -1560,7 +1648,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN4051"
NAME="AEN4142"
></A
><H3
><A
@ -1613,7 +1701,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> An entity table</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -1623,7 +1711,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN4067"
NAME="AEN4158"
></A
><H3
><A
@ -1680,7 +1768,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> An XML buffer.</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1697,7 +1785,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> An entity table</TD
>&nbsp;</TD
></TR
></TABLE
><P

View File

@ -115,7 +115,7 @@ SIZE="3"
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN6506"
NAME="AEN7224"
></A
><H2
>Name</H2
@ -123,7 +123,7 @@ NAME="AEN6506"
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN6509"
NAME="AEN7227"
></A
><H2
>Synopsis</H2
@ -277,7 +277,7 @@ HREF="gnome-xml-htmlparser.html#HTMLPARSEFILE"
><DIV
CLASS="REFSECT1"
><A
NAME="AEN6547"
NAME="AEN7265"
></A
><H2
>Description</H2
@ -287,248 +287,131 @@ NAME="AEN6547"
><DIV
CLASS="REFSECT1"
><A
NAME="AEN6550"
NAME="AEN7268"
></A
><H2
>Details</H2
><DIV
CLASS="REFSECT2"
><A
NAME="AEN6552"
NAME="AEN7270"
></A
><H3
><A
NAME="HTMLPARSERCTXT"
></A
>htmlParserCtxt</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef xmlParserCtxt htmlParserCtxt;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6557"
NAME="AEN7274"
></A
><H3
><A
NAME="HTMLPARSERCTXTPTR"
></A
>htmlParserCtxtPtr</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef xmlParserCtxtPtr htmlParserCtxtPtr;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6562"
NAME="AEN7278"
></A
><H3
><A
NAME="HTMLPARSERNODEINFO"
></A
>htmlParserNodeInfo</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef xmlParserNodeInfo htmlParserNodeInfo;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6567"
NAME="AEN7282"
></A
><H3
><A
NAME="HTMLSAXHANDLER"
></A
>htmlSAXHandler</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef xmlSAXHandler htmlSAXHandler;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6572"
NAME="AEN7286"
></A
><H3
><A
NAME="HTMLSAXHANDLERPTR"
></A
>htmlSAXHandlerPtr</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef xmlSAXHandlerPtr htmlSAXHandlerPtr;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6577"
NAME="AEN7290"
></A
><H3
><A
NAME="HTMLPARSERINPUT"
></A
>htmlParserInput</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef xmlParserInput htmlParserInput;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6582"
NAME="AEN7294"
></A
><H3
><A
NAME="HTMLPARSERINPUTPTR"
></A
>htmlParserInputPtr</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef xmlParserInputPtr htmlParserInputPtr;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6587"
NAME="AEN7298"
></A
><H3
><A
NAME="HTMLDOCPTR"
></A
>htmlDocPtr</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef xmlDocPtr htmlDocPtr;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6592"
NAME="AEN7302"
></A
><H3
><A
NAME="HTMLNODEPTR"
></A
>htmlNodePtr</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef xmlNodePtr htmlNodePtr;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6597"
NAME="AEN7306"
></A
><H3
><A
@ -584,7 +467,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> The tag name</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -599,7 +482,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>the related htmlElemDescPtr or NULL if not found.</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -609,7 +492,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6618"
NAME="AEN7327"
></A
><H3
><A
@ -667,7 +550,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the entity name</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -682,7 +565,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>the associated htmlEntityDescPtr if found, NULL otherwise.</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -692,7 +575,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6640"
NAME="AEN7349"
></A
><H3
><A
@ -754,7 +637,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> an HTML parser context</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -771,7 +654,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> location to store the entity name</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -786,8 +669,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>the associated htmlEntityDescPtr if found, or NULL otherwise,
if non-NULL *str will have to be freed by the caller.</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -797,7 +679,7 @@ if non-NULL *str will have to be freed by the caller.</TD
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6667"
NAME="AEN7376"
></A
><H3
><A
@ -856,7 +738,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> an HTML parser context</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -871,7 +753,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>the value parsed (as an int)</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -881,7 +763,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6689"
NAME="AEN7398"
></A
><H3
><A
@ -938,7 +820,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> an HTML parser context</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -948,7 +830,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6707"
NAME="AEN7416"
></A
><H3
><A
@ -1012,7 +894,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> a pointer to an array of CHAR</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1029,7 +911,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> a free form C string describing the HTML document encoding, or NULL</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1046,7 +928,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the SAX handler block</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1063,7 +945,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> if using SAX, this pointer will be provided on callbacks. </TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1078,7 +960,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>the resulting document tree</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -1088,7 +970,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6741"
NAME="AEN7450"
></A
><H3
><A
@ -1145,7 +1027,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> a pointer to an array of CHAR</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1162,7 +1044,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> a free form C string describing the HTML document encoding, or NULL</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1177,7 +1059,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>the resulting document tree</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -1187,7 +1069,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6766"
NAME="AEN7475"
></A
><H3
><A
@ -1249,7 +1131,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the filename</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1266,7 +1148,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> a free form C string describing the HTML document encoding, or NULL</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1283,7 +1165,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the SAX handler block</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1300,7 +1182,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> if using SAX, this pointer will be provided on callbacks. </TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1315,7 +1197,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>the resulting document tree</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -1325,7 +1207,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6799"
NAME="AEN7508"
></A
><H3
><A
@ -1380,7 +1262,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the filename</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1397,7 +1279,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> a free form C string describing the HTML document encoding, or NULL</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -1412,7 +1294,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>the resulting document tree</TD
>&nbsp;</TD
></TR
></TABLE
><P

View File

@ -115,7 +115,7 @@ SIZE="3"
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN6828"
NAME="AEN7537"
></A
><H2
>Name</H2
@ -123,7 +123,7 @@ NAME="AEN6828"
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN6831"
NAME="AEN7540"
></A
><H2
>Synopsis</H2
@ -188,7 +188,7 @@ HREF="gnome-xml-tree.html#XMLDOCPTR"
><DIV
CLASS="REFSECT1"
><A
NAME="AEN6845"
NAME="AEN7554"
></A
><H2
>Description</H2
@ -198,14 +198,14 @@ NAME="AEN6845"
><DIV
CLASS="REFSECT1"
><A
NAME="AEN6848"
NAME="AEN7557"
></A
><H2
>Details</H2
><DIV
CLASS="REFSECT2"
><A
NAME="AEN6850"
NAME="AEN7559"
></A
><H3
><A
@ -221,7 +221,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define HTML_TEXT_NODE XML_TEXT_NODE</PRE
>#define HTML_TEXT_NODE</PRE
></TD
></TR
></TABLE
@ -231,7 +231,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6855"
NAME="AEN7564"
></A
><H3
><A
@ -247,7 +247,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define HTML_ENTITY_REF_NODE XML_ENTITY_REF_NODE</PRE
>#define HTML_ENTITY_REF_NODE</PRE
></TD
></TR
></TABLE
@ -257,7 +257,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6860"
NAME="AEN7569"
></A
><H3
><A
@ -273,7 +273,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define HTML_COMMENT_NODE XML_COMMENT_NODE</PRE
>#define HTML_COMMENT_NODE</PRE
></TD
></TR
></TABLE
@ -283,7 +283,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6865"
NAME="AEN7574"
></A
><H3
><A
@ -342,7 +342,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the document</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -359,7 +359,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> OUT: the memory pointer</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -376,7 +376,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> OUT: the memory lenght</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -386,7 +386,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6890"
NAME="AEN7599"
></A
><H3
><A
@ -443,7 +443,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the FILE*</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -460,7 +460,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the document</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -470,7 +470,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6911"
NAME="AEN7620"
></A
><H3
><A
@ -524,7 +524,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the filename</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -541,7 +541,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the document</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -556,7 +556,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the number of byte written or -1 in case of failure.</TD
>&nbsp;</TD
></TR
></TABLE
><P

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -115,7 +115,7 @@ SIZE="3"
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN4617"
NAME="AEN5157"
></A
><H2
>Name</H2
@ -123,7 +123,7 @@ NAME="AEN4617"
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN4620"
NAME="AEN5160"
></A
><H2
>Synopsis</H2
@ -157,7 +157,7 @@ HREF="gnome-xml-xml-error.html#XMLPARSERWARNING"
><DIV
CLASS="REFSECT1"
><A
NAME="AEN4625"
NAME="AEN5165"
></A
><H2
>Description</H2
@ -167,14 +167,14 @@ NAME="AEN4625"
><DIV
CLASS="REFSECT1"
><A
NAME="AEN4628"
NAME="AEN5168"
></A
><H2
>Details</H2
><DIV
CLASS="REFSECT2"
><A
NAME="AEN4630"
NAME="AEN5170"
></A
><H3
><A
@ -227,7 +227,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> an XML parser context</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -244,7 +244,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the message to display/transmit</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -261,7 +261,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> extra parameters for the message display</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -271,7 +271,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN4653"
NAME="AEN5193"
></A
><H3
><A
@ -324,7 +324,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> an XML parser context</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -341,7 +341,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the message to display/transmit</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -358,7 +358,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> extra parameters for the message display</TD
>&nbsp;</TD
></TR
></TABLE
><P

View File

@ -103,7 +103,7 @@ ALIGN="right"
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN6940"
NAME="AEN7649"
></A
><H2
>Name</H2
@ -111,7 +111,7 @@ NAME="AEN6940"
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN6943"
NAME="AEN7652"
></A
><H2
>Synopsis</H2
@ -216,7 +216,7 @@ HREF="XMLXPATHCONTEXTPTR"
><DIV
CLASS="REFSECT1"
><A
NAME="AEN6968"
NAME="AEN7677"
></A
><H2
>Description</H2
@ -226,14 +226,14 @@ NAME="AEN6968"
><DIV
CLASS="REFSECT1"
><A
NAME="AEN6971"
NAME="AEN7680"
></A
><H2
>Details</H2
><DIV
CLASS="REFSECT2"
><A
NAME="AEN6973"
NAME="AEN7682"
></A
><H3
><A
@ -249,7 +249,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XPATH_UNDEFINED 0</PRE
>#define XPATH_UNDEFINED</PRE
></TD
></TR
></TABLE
@ -259,7 +259,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6978"
NAME="AEN7687"
></A
><H3
><A
@ -275,7 +275,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XPATH_NODESET 1</PRE
>#define XPATH_NODESET</PRE
></TD
></TR
></TABLE
@ -285,7 +285,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6983"
NAME="AEN7692"
></A
><H3
><A
@ -301,7 +301,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XPATH_BOOLEAN 2</PRE
>#define XPATH_BOOLEAN</PRE
></TD
></TR
></TABLE
@ -311,7 +311,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6988"
NAME="AEN7697"
></A
><H3
><A
@ -327,7 +327,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XPATH_NUMBER 3</PRE
>#define XPATH_NUMBER</PRE
></TD
></TR
></TABLE
@ -337,7 +337,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6993"
NAME="AEN7702"
></A
><H3
><A
@ -353,7 +353,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XPATH_STRING 4</PRE
>#define XPATH_STRING</PRE
></TD
></TR
></TABLE
@ -363,7 +363,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN6998"
NAME="AEN7707"
></A
><H3
><A
@ -442,7 +442,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN7017"
NAME="AEN7726"
></A
><H3
><A
@ -501,7 +501,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the XML document</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -518,7 +518,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the variable list</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -535,7 +535,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the function list</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -552,7 +552,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the namespace list</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -567,7 +567,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>the xmlXPathContext just allocated.</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -577,7 +577,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN7050"
NAME="AEN7759"
></A
><H3
><A
@ -630,7 +630,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the context to free</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -640,7 +640,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN7066"
NAME="AEN7775"
></A
><H3
><A
@ -700,7 +700,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the XPath expression</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -717,7 +717,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the XPath context</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -732,8 +732,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>the xmlXPathObjectPtr resulting from the eveluation or NULL.
the caller has to free the object.</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -743,7 +742,7 @@ the caller has to free the object.</TD
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN7092"
NAME="AEN7801"
></A
><H3
><A
@ -796,7 +795,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the object to free</TD
>&nbsp;</TD
></TR
></TABLE
><P
@ -806,7 +805,7 @@ VALIGN="TOP"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN7108"
NAME="AEN7817"
></A
><H3
><A
@ -866,7 +865,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the XPath expression</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -883,7 +882,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the XPath context</TD
>&nbsp;</TD
></TR
><TR
><TD
@ -898,8 +897,7 @@ CLASS="EMPHASIS"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
>the xmlXPathObjectPtr resulting from the eveluation or NULL.
the caller has to free the object.</TD
>&nbsp;</TD
></TR
></TABLE
><P

View File

@ -5,6 +5,7 @@
<ANCHOR id ="XMLPARSERNODEINFO" href="gnome-xml/gnome-xml-parser.html#XMLPARSERNODEINFO">
<ANCHOR id ="XMLPARSERNODEINFOSEQ" href="gnome-xml/gnome-xml-parser.html#XMLPARSERNODEINFOSEQ">
<ANCHOR id ="XMLPARSERNODEINFOSEQPTR" href="gnome-xml/gnome-xml-parser.html#XMLPARSERNODEINFOSEQPTR">
<ANCHOR id ="XMLPARSERINPUTSTATE" href="gnome-xml/gnome-xml-parser.html#XMLPARSERINPUTSTATE">
<ANCHOR id ="XMLPARSERCTXT" href="gnome-xml/gnome-xml-parser.html#XMLPARSERCTXT">
<ANCHOR id ="XMLPARSERCTXTPTR" href="gnome-xml/gnome-xml-parser.html#XMLPARSERCTXTPTR">
<ANCHOR id ="XMLSAXLOCATOR" href="gnome-xml/gnome-xml-parser.html#XMLSAXLOCATOR">
@ -12,6 +13,7 @@
<ANCHOR id ="RESOLVEENTITYSAXFUNC" href="gnome-xml/gnome-xml-parser.html#RESOLVEENTITYSAXFUNC">
<ANCHOR id ="INTERNALSUBSETSAXFUNC" href="gnome-xml/gnome-xml-parser.html#INTERNALSUBSETSAXFUNC">
<ANCHOR id ="GETENTITYSAXFUNC" href="gnome-xml/gnome-xml-parser.html#GETENTITYSAXFUNC">
<ANCHOR id ="GETPARAMETERENTITYSAXFUNC" href="gnome-xml/gnome-xml-parser.html#GETPARAMETERENTITYSAXFUNC">
<ANCHOR id ="ENTITYDECLSAXFUNC" href="gnome-xml/gnome-xml-parser.html#ENTITYDECLSAXFUNC">
<ANCHOR id ="NOTATIONDECLSAXFUNC" href="gnome-xml/gnome-xml-parser.html#NOTATIONDECLSAXFUNC">
<ANCHOR id ="ATTRIBUTEDECLSAXFUNC" href="gnome-xml/gnome-xml-parser.html#ATTRIBUTEDECLSAXFUNC">
@ -28,6 +30,7 @@
<ANCHOR id ="IGNORABLEWHITESPACESAXFUNC" href="gnome-xml/gnome-xml-parser.html#IGNORABLEWHITESPACESAXFUNC">
<ANCHOR id ="PROCESSINGINSTRUCTIONSAXFUNC" href="gnome-xml/gnome-xml-parser.html#PROCESSINGINSTRUCTIONSAXFUNC">
<ANCHOR id ="COMMENTSAXFUNC" href="gnome-xml/gnome-xml-parser.html#COMMENTSAXFUNC">
<ANCHOR id ="CDATABLOCKSAXFUNC" href="gnome-xml/gnome-xml-parser.html#CDATABLOCKSAXFUNC">
<ANCHOR id ="WARNINGSAXFUNC" href="gnome-xml/gnome-xml-parser.html#WARNINGSAXFUNC">
<ANCHOR id ="ERRORSAXFUNC" href="gnome-xml/gnome-xml-parser.html#ERRORSAXFUNC">
<ANCHOR id ="FATALERRORSAXFUNC" href="gnome-xml/gnome-xml-parser.html#FATALERRORSAXFUNC">
@ -133,6 +136,7 @@
<ANCHOR id ="XMLNEWTEXTLEN" href="gnome-xml/gnome-xml-tree.html#XMLNEWTEXTLEN">
<ANCHOR id ="XMLNEWDOCCOMMENT" href="gnome-xml/gnome-xml-tree.html#XMLNEWDOCCOMMENT">
<ANCHOR id ="XMLNEWCOMMENT" href="gnome-xml/gnome-xml-tree.html#XMLNEWCOMMENT">
<ANCHOR id ="XMLNEWCDATABLOCK" href="gnome-xml/gnome-xml-tree.html#XMLNEWCDATABLOCK">
<ANCHOR id ="XMLNEWREFERENCE" href="gnome-xml/gnome-xml-tree.html#XMLNEWREFERENCE">
<ANCHOR id ="XMLCOPYNODE" href="gnome-xml/gnome-xml-tree.html#XMLCOPYNODE">
<ANCHOR id ="XMLCOPYNODELIST" href="gnome-xml/gnome-xml-tree.html#XMLCOPYNODELIST">
@ -184,6 +188,7 @@
<ANCHOR id ="XMLGETPREDEFINEDENTITY" href="gnome-xml/gnome-xml-entities.html#XMLGETPREDEFINEDENTITY">
<ANCHOR id ="XMLGETDOCENTITY" href="gnome-xml/gnome-xml-entities.html#XMLGETDOCENTITY">
<ANCHOR id ="XMLGETDTDENTITY" href="gnome-xml/gnome-xml-entities.html#XMLGETDTDENTITY">
<ANCHOR id ="XMLGETPARAMETERENTITY" href="gnome-xml/gnome-xml-entities.html#XMLGETPARAMETERENTITY">
<ANCHOR id ="XMLENCODEENTITIES" href="gnome-xml/gnome-xml-entities.html#XMLENCODEENTITIES">
<ANCHOR id ="XMLENCODEENTITIESREENTRANT" href="gnome-xml/gnome-xml-entities.html#XMLENCODEENTITIESREENTRANT">
<ANCHOR id ="XMLCREATEENTITIESTABLE" href="gnome-xml/gnome-xml-entities.html#XMLCREATEENTITIESTABLE">
@ -191,6 +196,10 @@
<ANCHOR id ="XMLFREEENTITIESTABLE" href="gnome-xml/gnome-xml-entities.html#XMLFREEENTITIESTABLE">
<ANCHOR id ="XMLDUMPENTITIESTABLE" href="gnome-xml/gnome-xml-entities.html#XMLDUMPENTITIESTABLE">
<ANCHOR id ="GNOME-XML-VALID" href="gnome-xml/gnome-xml-valid.html">
<ANCHOR id ="XMLVALIDITYERRORFUNC" href="gnome-xml/gnome-xml-valid.html#XMLVALIDITYERRORFUNC">
<ANCHOR id ="XMLVALIDITYWARNINGFUNC" href="gnome-xml/gnome-xml-valid.html#XMLVALIDITYWARNINGFUNC">
<ANCHOR id ="XMLPARSERVALIDITYERROR" href="gnome-xml/gnome-xml-valid.html#XMLPARSERVALIDITYERROR">
<ANCHOR id ="XMLPARSERVALIDITYWARNING" href="gnome-xml/gnome-xml-valid.html#XMLPARSERVALIDITYWARNING">
<ANCHOR id ="XML-MIN-NOTATION-TABLE" href="gnome-xml/gnome-xml-valid.html#XML-MIN-NOTATION-TABLE">
<ANCHOR id ="XMLNOTATIONTABLEPTR" href="gnome-xml/gnome-xml-valid.html#XMLNOTATIONTABLEPTR">
<ANCHOR id ="XML-MIN-ELEMENT-TABLE" href="gnome-xml/gnome-xml-valid.html#XML-MIN-ELEMENT-TABLE">
@ -215,10 +224,23 @@
<ANCHOR id ="XMLCOPYATTRIBUTETABLE" href="gnome-xml/gnome-xml-valid.html#XMLCOPYATTRIBUTETABLE">
<ANCHOR id ="XMLFREEATTRIBUTETABLE" href="gnome-xml/gnome-xml-valid.html#XMLFREEATTRIBUTETABLE">
<ANCHOR id ="XMLDUMPATTRIBUTETABLE" href="gnome-xml/gnome-xml-valid.html#XMLDUMPATTRIBUTETABLE">
<ANCHOR id ="XMLVALIDATEROOT" href="gnome-xml/gnome-xml-valid.html#XMLVALIDATEROOT">
<ANCHOR id ="XMLVALIDATEELEMENTDECL" href="gnome-xml/gnome-xml-valid.html#XMLVALIDATEELEMENTDECL">
<ANCHOR id ="XMLVALIDATEATTRIBUTEDECL" href="gnome-xml/gnome-xml-valid.html#XMLVALIDATEATTRIBUTEDECL">
<ANCHOR id ="XMLVALIDATENOTATIONDECL" href="gnome-xml/gnome-xml-valid.html#XMLVALIDATENOTATIONDECL">
<ANCHOR id ="XMLVALIDATEDTD" href="gnome-xml/gnome-xml-valid.html#XMLVALIDATEDTD">
<ANCHOR id ="XMLVALIDATEDOCUMENT" href="gnome-xml/gnome-xml-valid.html#XMLVALIDATEDOCUMENT">
<ANCHOR id ="XMLVALIDATEELEMENT" href="gnome-xml/gnome-xml-valid.html#XMLVALIDATEELEMENT">
<ANCHOR id ="XMLVALIDATEONEELEMENT" href="gnome-xml/gnome-xml-valid.html#XMLVALIDATEONEELEMENT">
<ANCHOR id ="XMLVALIDATEONEATTRIBUTE" href="gnome-xml/gnome-xml-valid.html#XMLVALIDATEONEATTRIBUTE">
<ANCHOR id ="XMLISMIXEDELEMENT" href="gnome-xml/gnome-xml-valid.html#XMLISMIXEDELEMENT">
<ANCHOR id ="GNOME-XML-XML-ERROR" href="gnome-xml/gnome-xml-xml-error.html">
<ANCHOR id ="XMLPARSERERROR" href="gnome-xml/gnome-xml-xml-error.html#XMLPARSERERROR">
<ANCHOR id ="XMLPARSERWARNING" href="gnome-xml/gnome-xml-xml-error.html#XMLPARSERWARNING">
<ANCHOR id ="GNOME-XML-PARSERINTERNALS" href="gnome-xml/gnome-xml-parserinternals.html">
<ANCHOR id ="CHARVAL" href="gnome-xml/gnome-xml-parserinternals.html#CHARVAL">
<ANCHOR id ="NEXTCHARVAL" href="gnome-xml/gnome-xml-parserinternals.html#NEXTCHARVAL">
<ANCHOR id ="SKIPCHARVAL" href="gnome-xml/gnome-xml-parserinternals.html#SKIPCHARVAL">
<ANCHOR id ="IS-CHAR" href="gnome-xml/gnome-xml-parserinternals.html#IS-CHAR">
<ANCHOR id ="IS-BLANK" href="gnome-xml/gnome-xml-parserinternals.html#IS-BLANK">
<ANCHOR id ="IS-BASECHAR" href="gnome-xml/gnome-xml-parserinternals.html#IS-BASECHAR">
@ -235,6 +257,8 @@
<ANCHOR id ="XMLCREATEFILEPARSERCTXT" href="gnome-xml/gnome-xml-parserinternals.html#XMLCREATEFILEPARSERCTXT">
<ANCHOR id ="XMLCREATEMEMORYPARSERCTXT" href="gnome-xml/gnome-xml-parserinternals.html#XMLCREATEMEMORYPARSERCTXT">
<ANCHOR id ="XMLFREEPARSERCTXT" href="gnome-xml/gnome-xml-parserinternals.html#XMLFREEPARSERCTXT">
<ANCHOR id ="XMLNEWPARSERCTXT" href="gnome-xml/gnome-xml-parserinternals.html#XMLNEWPARSERCTXT">
<ANCHOR id ="XMLSWITCHENCODING" href="gnome-xml/gnome-xml-parserinternals.html#XMLSWITCHENCODING">
<ANCHOR id ="XMLHANDLEENTITY" href="gnome-xml/gnome-xml-parserinternals.html#XMLHANDLEENTITY">
<ANCHOR id ="XMLNEWENTITYINPUTSTREAM" href="gnome-xml/gnome-xml-parserinternals.html#XMLNEWENTITYINPUTSTREAM">
<ANCHOR id ="XMLPUSHINPUT" href="gnome-xml/gnome-xml-parserinternals.html#XMLPUSHINPUT">
@ -247,6 +271,7 @@
<ANCHOR id ="XMLNAMESPACEPARSENSDEF" href="gnome-xml/gnome-xml-parserinternals.html#XMLNAMESPACEPARSENSDEF">
<ANCHOR id ="XMLPARSEQUOTEDSTRING" href="gnome-xml/gnome-xml-parserinternals.html#XMLPARSEQUOTEDSTRING">
<ANCHOR id ="XMLPARSENAMESPACE" href="gnome-xml/gnome-xml-parserinternals.html#XMLPARSENAMESPACE">
<ANCHOR id ="XMLSCANNAME" href="gnome-xml/gnome-xml-parserinternals.html#XMLSCANNAME">
<ANCHOR id ="XMLPARSENAME" href="gnome-xml/gnome-xml-parserinternals.html#XMLPARSENAME">
<ANCHOR id ="XMLPARSENMTOKEN" href="gnome-xml/gnome-xml-parserinternals.html#XMLPARSENMTOKEN">
<ANCHOR id ="XMLPARSEENTITYVALUE" href="gnome-xml/gnome-xml-parserinternals.html#XMLPARSEENTITYVALUE">
@ -289,6 +314,7 @@
<ANCHOR id ="XMLPARSESDDECL" href="gnome-xml/gnome-xml-parserinternals.html#XMLPARSESDDECL">
<ANCHOR id ="XMLPARSEXMLDECL" href="gnome-xml/gnome-xml-parserinternals.html#XMLPARSEXMLDECL">
<ANCHOR id ="XMLPARSEMISC" href="gnome-xml/gnome-xml-parserinternals.html#XMLPARSEMISC">
<ANCHOR id ="XMLPARSEEXTERNALSUBSET" href="gnome-xml/gnome-xml-parserinternals.html#XMLPARSEEXTERNALSUBSET">
<ANCHOR id ="XML-SUBSTITUTE-NONE" href="gnome-xml/gnome-xml-parserinternals.html#XML-SUBSTITUTE-NONE">
<ANCHOR id ="XML-SUBSTITUTE-REF" href="gnome-xml/gnome-xml-parserinternals.html#XML-SUBSTITUTE-REF">
<ANCHOR id ="XML-SUBSTITUTE-PEREF" href="gnome-xml/gnome-xml-parserinternals.html#XML-SUBSTITUTE-PEREF">

View File

@ -1,23 +1,54 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>The XML library for Gnome</title>
<meta name="GENERATOR" content="amaya V1.3b">
<title>The XML library for Gnome</title>
<meta name="GENERATOR" content="amaya V2.1">
</head>
<body bgcolor="#ffffff">
<body bgcolor="#ffffff">
<h1 align="center">The XML library for Gnome</h1>
<p>
This document describes the <a href="http://www.w3.org/XML/">XML</a> library
provideed in the <a href="http://www.gnome.org/">Gnome</a> framework. XML is a
standard to build tag based structured documents. The internal document
repesentation is as close as possible to the <a
href="http://www.w3.org/DOM/">DOM</a> interfaces.</p>
<p>This document describes the <a href="http://www.w3.org/XML/">XML</a>
library provideed in the <a href="http://www.gnome.org/">Gnome</a> framework.
XML is a standard to build tag based structured documents/data. </p>
<p>The internal document repesentation is as close as possible to the <a
href="http://www.w3.org/DOM/">DOM</a> interfaces. </p>
<p>Libxml also has a <a href="http://www.megginson.com/SAX/index.html">SAX
interface</a>, <a href="mailto:james@daa.com.au">James Henstridge</a> made <a
href="http://www.daa.com.au/~james/gnome/xml-sax/xml-sax.html">a nice
documentation</a> expaining how to use it. The interface is as compatible as
possible with <a href="http://www.jclark.com/xml/expat.html">Expat</a>
one.</p>
<p>The code is commented in a <a href=""></a>way which allow <a
href="http://rpmfind.net/veillard/XML/libxml.html">extensive documentation</a>
to be automatically extracted.</p>
<p>There is also a mailing-list <a
href="xml@rufus.w3.org">xml@rufus.w3.org</a> for libxml, with an <a
href="http://rpmfind.net/veillard/XML/messages">on-line archive</a>. To
subscribe to this majordomo based list, send a mail to <a
href="majordomo@rufus.w3.org">majordomo@rufus.w3.org</a> with "subscribe xml"
in the <strong>content</strong> of the message.</p>
<p>This library is released both under the W3C Copyright and the GNU LGP,
basically everybody should be happy, if not, drop me a mail.</p>
<p>People are invited to use the <a
href="http://cvs.gnome.org/lxr/source/gdome/">gdome Gnome module to</a> get a
full DOM interface, thanks to <a href="mailto:raph@levien.com">Raph
Levien</a>, check his <a
href="http://www.levien.com/gnome/domination.html">DOMination paper</a>. He
uses it for his implementation of <a
href="http://www.w3.org/Graphics/SVG/">SVG</a> called <a
href="http://www.levien.com/svg/">gill</a>.</p>
<h2>xml</h2>
<p>
XML is a standard for markup based structured documents, here is <a
<p>XML is a standard for markup based structured documents, here is <a
name="example">an example</a>:</p>
<pre>&lt;?xml version="1.0"?>
&lt;EXAMPLE prop1="gnome is great" prop2="&amp;amp; linux too">
@ -31,17 +62,17 @@ name="example">an example</a>:</p>
&lt;p>...&lt;/p>
&lt;/chapter>
&lt;/EXAMPLE></pre>
<p>
The first line specify that it's an XML document and gives useful informations
about it's encoding. Then the document is a text format whose structure is
specified by tags between brackets. <strong>Each tag opened have to be
closed</strong> XML is pedantic about this, not that for example the image
tag has no content (just an attribute) and is closed by ending up the tag
with <code>/></code>.</p>
<p>The first line specify that it's an XML document and gives useful
informations about it's encoding. Then the document is a text format whose
structure is specified by tags between brackets. <strong>Each tag opened have
to be closed</strong> XML is pedantic about this, not that for example the
image tag has no content (just an attribute) and is closed by ending up the
tag with <code>/></code>.</p>
<h2>The tree output</h2>
<p>
The parser returns a tree built during the document analysis. The value
<p>The parser returns a tree built during the document analysis. The value
returned is an <strong>xmlDocPtr</strong> (i.e. a pointer to an
<strong>xmlDoc</strong> structure). This structure contains informations like
the file name, the document type, and a <strong>root</strong> pointer which
@ -50,13 +81,13 @@ which is the document). The tree is made of <strong>xmlNode</strong>s, chained
in double linked lists of siblings and with childs&lt;->parent relationship.
An xmlNode can also carry properties (a chain of xmlAttr structures). An
attribute may have a value which is a list of TEXT or ENTITY_REF nodes.</p>
<p>
Here is an example (erroneous w.r.t. the XML spec since there should be only
one ELEMENT under the root):</p>
<p>
<img src="structure.gif" alt=" structure.gif "></p>
<p>
In the source package there is a small program (not installed by default)
<p>Here is an example (erroneous w.r.t. the XML spec since there should be
only one ELEMENT under the root):</p>
<p><img src="structure.gif" alt=" structure.gif "></p>
<p>In the source package there is a small program (not installed by default)
called <strong>tester</strong> which parses XML files given as argument and
prints them back as parsed, this is useful to detect errors both in XML code
and in the XML parser itself. It has an option <strong>--debug</strong> which
@ -91,12 +122,12 @@ standalone=true
ELEMENT p
TEXT
content=...</pre>
<p>
This should be useful to learn the internal representation model.</p>
<p>This should be useful to learn the internal representation model.</p>
<h2>The XML library interfaces</h2>
<p>
This section is directly intended to help programmers getting bootstrapped
<p>This section is directly intended to help programmers getting bootstrapped
using the XML library from the C language. It doesn't intent to be extensive,
I hope the automatically generated docs will provide the completeness
required, but as a separated set of documents. The interfaces of the XML
@ -105,35 +136,33 @@ interested in a higher level API should <a href="#DOM">look at DOM</a>
(unfortunately not completed).</p>
<h3>Invoking the parser</h3>
<p>
Usually, the first thing to do is to read an XML input, the parser accepts to
parse both memory mapped documents or direct files. The functions are defined
in "parser.h":</p>
<p>Usually, the first thing to do is to read an XML input, the parser accepts
to parse both memory mapped documents or direct files. The functions are
defined in "parser.h":</p>
<dl>
<dt><code>xmlDocPtr xmlParseMemory(char *buffer, int size);</code></dt>
<dd><p>
parse a zero terminated string containing the document</p>
</dd>
<dt><code>xmlDocPtr xmlParseMemory(char *buffer, int size);</code></dt>
<dd><p>parse a zero terminated string containing the document</p>
</dd>
</dl>
<dl>
<dt><code>xmlDocPtr xmlParseFile(const char *filename);</code></dt>
<dd><p>
parse an XML document contained in a file (possibly compressed)</p>
</dd>
<dt><code>xmlDocPtr xmlParseFile(const char *filename);</code></dt>
<dd><p>parse an XML document contained in a file (possibly compressed)</p>
</dd>
</dl>
<p>
This returns a pointer to the document structure (or NULL in case of
<p>This returns a pointer to the document structure (or NULL in case of
failure).</p>
<p>
A couple of comments can be made, first this mean that the parser is
<p>A couple of comments can be made, first this mean that the parser is
memory-hungry, first to load the document in memory, second to build the tree.
Reading a document without building the tree will be possible in the future by
pluggin the code to the SAX interface (see SAX.c).</p>
<h3>Building a tree from scratch</h3>
<p>
The other way to get an XML tree in memory is by building it. Basically there
is a set of functions dedicated to building new elements, those are also
<p>The other way to get an XML tree in memory is by building it. Basically
there is a set of functions dedicated to building new elements, those are also
described in "tree.h", here is for example the piece of code producing the
example used before:</p>
<pre> xmlDocPtr doc;
@ -150,129 +179,120 @@ example used before:</p>
subtree = xmlNewChild(tree, NULL, "p", "bla bla bla ...");
subtree = xmlNewChild(tree, NULL, "image", NULL);
xmlSetProp(subtree, "href", "linus.gif");</pre>
<p>
Not really rocket science ...</p>
<p>Not really rocket science ...</p>
<h3>Traversing the tree</h3>
<p>
Basically by including "tree.h" your code has access to the internal structure
of all the element of the tree. The names should be somewhat simple like
<strong>parent</strong>, <strong>childs</strong>, <strong>next</strong>,
<p>Basically by including "tree.h" your code has access to the internal
structure of all the element of the tree. The names should be somewhat simple
like <strong>parent</strong>, <strong>childs</strong>, <strong>next</strong>,
<strong>prev</strong>, <strong>properties</strong>, etc... For example still
with the previous example:</p>
<pre><code>doc->root->childs->childs</code></pre>
<p>
points to the title element,</p>
<p>points to the title element,</p>
<pre>doc->root->childs->next->child->child</pre>
<p>
points to the text node containing the chapter titlle "The Linux adventure"
<p>points to the text node containing the chapter titlle "The Linux adventure"
and</p>
<pre>doc->root->properties->next->val</pre>
<p>
points to the entity reference containing the value of "&amp;linux" at the
<p>points to the entity reference containing the value of "&amp;linux" at the
beginning of the second attribute of the root element "EXAMPLE".</p>
<h3>Modifying the tree</h3>
<p>
functions are provided to read and write the document content:</p>
<p>functions are provided to read and write the document content:</p>
<dl>
<dt><code>xmlAttrPtr xmlSetProp(xmlNodePtr node, const CHAR *name, const CHAR
*value);</code></dt>
<dd><p>
This set (or change) an attribute carried by an ELEMENT node the value can be
NULL</p>
</dd>
<dt><code>xmlAttrPtr xmlSetProp(xmlNodePtr node, const CHAR *name, const
CHAR *value);</code></dt>
<dd><p>This set (or change) an attribute carried by an ELEMENT node the
value can be NULL</p>
</dd>
</dl>
<dl>
<dt><code>const CHAR *xmlGetProp(xmlNodePtr node, const CHAR
*name);</code></dt>
<dd><p>
This function returns a pointer to the property content, note that no extra
copy is made</p>
</dd>
<dt><code>const CHAR *xmlGetProp(xmlNodePtr node, const CHAR
*name);</code></dt>
<dd><p>This function returns a pointer to the property content, note that
no extra copy is made</p>
</dd>
</dl>
<p>
Two functions must be used to read an write the text associated to
<p>Two functions must be used to read an write the text associated to
elements:</p>
<dl>
<dt><code>xmlNodePtr xmlStringGetNodeList(xmlDocPtr doc, const CHAR
*value);</code></dt>
<dd><p>
This function takes an "external" string and convert it to one text node or
possibly to a list of entity and text nodes. All non-predefined entity
references like &amp;Gnome; will be stored internally as an entity node, hence
the result of the function may not be a single node.</p>
</dd>
<dt><code>xmlNodePtr xmlStringGetNodeList(xmlDocPtr doc, const CHAR
*value);</code></dt>
<dd><p>This function takes an "external" string and convert it to one text
node or possibly to a list of entity and text nodes. All non-predefined
entity references like &amp;Gnome; will be stored internally as an
entity node, hence the result of the function may not be a single
node.</p>
</dd>
</dl>
<dl>
<dt><code>CHAR *xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int
inLine);</code></dt>
<dd><p>
this is the dual function, which generate a new string containing the content
of the text and entity nodes. Note the extra argument inLine, if set to 1
instead of returning the &amp;Gnome; XML encoding in the string it will
substitute it with it's value say "GNU Network Object Model Environment". Set
it if you want to use the string for non XML usage like User Interface.</p>
</dd>
<dt><code>CHAR *xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int
inLine);</code></dt>
<dd><p>this is the dual function, which generate a new string containing
the content of the text and entity nodes. Note the extra argument
inLine, if set to 1 instead of returning the &amp;Gnome; XML encoding in
the string it will substitute it with it's value say "GNU Network Object
Model Environment". Set it if you want to use the string for non XML
usage like User Interface.</p>
</dd>
</dl>
<h3>Saving a tree</h3>
<p>
Basically 3 options are possible:</p>
<p>Basically 3 options are possible:</p>
<dl>
<dt><code>void xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int
*size);</code></dt>
<dd><p>
returns a buffer where the document has been saved</p>
</dd>
<dt><code>void xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int
*size);</code></dt>
<dd><p>returns a buffer where the document has been saved</p>
</dd>
</dl>
<dl>
<dt><code>extern void xmlDocDump(FILE *f, xmlDocPtr doc);</code></dt>
<dd><p>
dumps a buffer to an open file descriptor</p>
</dd>
<dt><code>extern void xmlDocDump(FILE *f, xmlDocPtr doc);</code></dt>
<dd><p>dumps a buffer to an open file descriptor</p>
</dd>
</dl>
<dl>
<dt><code>int xmlSaveFile(const char *filename, xmlDocPtr cur);</code></dt>
<dd><p>
save the document ot a file. In that case the compression interface is
triggered if turned on</p>
</dd>
<dt><code>int xmlSaveFile(const char *filename, xmlDocPtr cur);</code></dt>
<dd><p>save the document ot a file. In that case the compression interface
is triggered if turned on</p>
</dd>
</dl>
<h3>Compression</h3>
<p>
The library handle transparently compression when doing file based accesses,
the level of compression on saves can be tuned either globally or individually
for one file:</p>
<p>The library handle transparently compression when doing file based
accesses, the level of compression on saves can be tuned either globally or
individually for one file:</p>
<dl>
<dt><code>int xmlGetDocCompressMode (xmlDocPtr doc);</code></dt>
<dd><p>
Get the document compression ratio (0-9)</p>
</dd>
<dt><code>int xmlGetDocCompressMode (xmlDocPtr doc);</code></dt>
<dd><p>Get the document compression ratio (0-9)</p>
</dd>
</dl>
<dl>
<dt><code>void xmlSetDocCompressMode (xmlDocPtr doc, int mode);</code></dt>
<dd><p>
Set the document compression ratio</p>
</dd>
<dt><code>void xmlSetDocCompressMode (xmlDocPtr doc, int mode);</code></dt>
<dd><p>Set the document compression ratio</p>
</dd>
</dl>
<dl>
<dt><code>int xmlGetCompressMode(void);</code></dt>
<dd><p>
Get the default compression ratio</p>
</dd>
<dt><code>int xmlGetCompressMode(void);</code></dt>
<dd><p>Get the default compression ratio</p>
</dd>
</dl>
<dl>
<dt><code>void xmlSetCompressMode(int mode);</code></dt>
<dd><p>
set the default compression ratio</p>
</dd>
<dt><code>void xmlSetCompressMode(int mode);</code></dt>
<dd><p>set the default compression ratio</p>
</dd>
</dl>
<h2><a name="DOM">DOM Principles</a></h2>
<p>
<a href="http://www.w3.org/DOM/">DOM</a> stands for the <em>Document Object
<p><a href="http://www.w3.org/DOM/">DOM</a> stands for the <em>Document Object
Model</em> this is an API for accessing XML or HTML structured documents.
Native support for DOM in Gnome is on the way (module gnome-dom), and it will
be based on gnome-xml. This will be a far cleaner interface to manipulate XML
@ -280,20 +300,20 @@ files within Gnome since it won't expose the internal structure. DOM defiles a
set of IDL (or Java) interfaces allowing to traverse and manipulate a
document. The DOM library will allow accessing and modifying "live" documents
presents on other programs like this:</p>
<p>
<img src="DOM.gif" alt=" DOM.gif "></p>
<p>
This should help greatly doing things like modifying a gnumeric spreadsheet
<p><img src="DOM.gif" alt=" DOM.gif "></p>
<p>This should help greatly doing things like modifying a gnumeric spreadsheet
embedded in a GWP document for example.</p>
<h3><a name="Example">A real example</a></h3>
<p>
Here is a real size example, where the actual content of the application data
is not kept in the DOM tree but uses internal structures. It is based on
<p>Here is a real size example, where the actual content of the application
data is not kept in the DOM tree but uses internal structures. It is based on
a proposal to keep a database of jobs related to Gnome, with an XML based
storage structure. Here is an <a href="gjobs.xml">XML encoded jobs base</a>:
<pre>
&lt;?xml version="1.0"?>
storage structure. Here is an <a href="gjobs.xml">XML encoded jobs
base</a>:</p>
<pre>&lt;?xml version="1.0"?>
&lt;gjob:Helping xmlns:gjob="http://www.gnome.org/some-location">
&lt;gjob:Jobs>
@ -303,8 +323,8 @@ storage structure. Here is an <a href="gjobs.xml">XML encoded jobs base</a>:
&lt;gjob:Category>Development&lt;/gjob:Category>
&lt;gjob:Update>
&lt;gjob:Status>Open&lt;/gjob:Status>
&lt;gjob:Modified>Mon, 07 Jun 1999 20:27:45 -0400 MET DST&lt;/gjob:Modified>
&lt;gjob:Status>Open&lt;/gjob:Status>
&lt;gjob:Modified>Mon, 07 Jun 1999 20:27:45 -0400 MET DST&lt;/gjob:Modified>
&lt;gjob:Salary>USD 0.00&lt;/gjob:Salary>
&lt;/gjob:Update>
@ -315,17 +335,17 @@ storage structure. Here is an <a href="gjobs.xml">XML encoded jobs base</a>:
&lt;gjob:Contact>
&lt;gjob:Person>Nathan Clemons&lt;/gjob:Person>
&lt;gjob:Email>nathan@windsofstorm.net&lt;/gjob:Email>
&lt;gjob:Email>nathan@windsofstorm.net&lt;/gjob:Email>
&lt;gjob:Company>
&lt;/gjob:Company>
&lt;/gjob:Company>
&lt;gjob:Organisation>
&lt;/gjob:Organisation>
&lt;/gjob:Organisation>
&lt;gjob:Webpage>
&lt;/gjob:Webpage>
&lt;gjob:Snailmail>
&lt;/gjob:Snailmail>
&lt;gjob:Phone>
&lt;/gjob:Phone>
&lt;/gjob:Webpage>
&lt;gjob:Snailmail>
&lt;/gjob:Snailmail>
&lt;gjob:Phone>
&lt;/gjob:Phone>
&lt;/gjob:Contact>
&lt;gjob:Requirements>
@ -349,23 +369,18 @@ storage structure. Here is an <a href="gjobs.xml">XML encoded jobs base</a>:
&lt;/gjob:Jobs>
&lt;/gjob:Helping>
</pre>
<p>
While loading the XML file into an internal DOM tree is a matter of calling
only a couple of functions, browsing the tree to gather the informations
and generate the internals structures is harder, and more error prone.
</p>
<p>
The suggested principle is to be tolerant with respect to the input
structure. For example the ordering of the attributes is not significant,
Cthe XML specification is clear about it. It's also usually a good idea
to not be dependant of the orders of the childs of a given node, unless it
really makes things harder. Here is some code to parse the informations
for a person:
</p>
<pre>
/*
<p>While loading the XML file into an internal DOM tree is a matter of calling
only a couple of functions, browsing the tree to gather the informations and
generate the internals structures is harder, and more error prone.</p>
<p>The suggested principle is to be tolerant with respect to the input
structure. For example the ordering of the attributes is not significant, Cthe
XML specification is clear about it. It's also usually a good idea to not be
dependant of the orders of the childs of a given node, unless it really makes
things harder. Here is some code to parse the informations for a person:</p>
<pre>/*
* A person record
*/
typedef struct person {
@ -391,7 +406,7 @@ DEBUG("parsePerson\n");
ret = (personPtr) malloc(sizeof(person));
if (ret == NULL) {
fprintf(stderr,"out of memory\n");
return(NULL);
return(NULL);
}
memset(ret, 0, sizeof(person));
@ -399,38 +414,36 @@ DEBUG("parsePerson\n");
cur = cur->childs;
while (cur != NULL) {
if ((!strcmp(cur->name, "Person")) &amp;&amp; (cur->ns == ns))
ret->name = xmlNodeListGetString(doc, cur->childs, 1);
ret->name = xmlNodeListGetString(doc, cur->childs, 1);
if ((!strcmp(cur->name, "Email")) &amp;&amp; (cur->ns == ns))
ret->email = xmlNodeListGetString(doc, cur->childs, 1);
cur = cur->next;
ret->email = xmlNodeListGetString(doc, cur->childs, 1);
cur = cur->next;
}
return(ret);
}
</pre>
<p>
Here is a couple of things to notice:</p>
}</pre>
<p>Here is a couple of things to notice:</p>
<ul>
<li> Usually a recursive parsing style is the more convenient one,
XML data being by nature subject to repetitive constructs and usualy exibit
highly stuctured patterns.
<li> The two arguments of type <em>xmlDocPtr</em> and <em>xmlNsPtr</em>, i.e.
the pointer to the global XML document and the namespace reserved to the
application. Document wide information are needed for example to decode
entities and it's a good coding practice to define a namespace for your
application set of data and test that the element and attributes you're
analyzing actually pertains to your application space. This is done by a simple
equality test (cur->ns == ns).
<li> To retrieve text and attributes value, it is suggested to use
the function <em>xmlNodeListGetString</em> to gather all the text and
entity reference nodes generated by the DOM output and produce an
single text string.
<li>Usually a recursive parsing style is the more convenient one, XML data
being by nature subject to repetitive constructs and usualy exibit highly
stuctured patterns.</li>
<li>The two arguments of type <em>xmlDocPtr</em> and <em>xmlNsPtr</em>, i.e.
the pointer to the global XML document and the namespace reserved to the
application. Document wide information are needed for example to decode
entities and it's a good coding practice to define a namespace for your
application set of data and test that the element and attributes you're
analyzing actually pertains to your application space. This is done by a
simple equality test (cur->ns == ns).</li>
<li>To retrieve text and attributes value, it is suggested to use the
function <em>xmlNodeListGetString</em> to gather all the text and entity
reference nodes generated by the DOM output and produce an single text
string.</li>
</ul>
<p>
Here is another piece of code used to parse another level of the structure:
</p>
<pre>
/*
<p>Here is another piece of code used to parse another level of the
structure:</p>
<pre>/*
* a Description for a Job
*/
typedef struct job {
@ -455,7 +468,7 @@ DEBUG("parseJob\n");
ret = (jobPtr) malloc(sizeof(job));
if (ret == NULL) {
fprintf(stderr,"out of memory\n");
return(NULL);
return(NULL);
}
memset(ret, 0, sizeof(job));
@ -464,34 +477,32 @@ DEBUG("parseJob\n");
while (cur != NULL) {
if ((!strcmp(cur->name, "Project")) &amp;&amp; (cur->ns == ns)) {
ret->projectID = xmlGetProp(cur, "ID");
if (ret->projectID == NULL) {
fprintf(stderr, "Project has no ID\n");
}
}
ret->projectID = xmlGetProp(cur, "ID");
if (ret->projectID == NULL) {
fprintf(stderr, "Project has no ID\n");
}
}
if ((!strcmp(cur->name, "Application")) &amp;&amp; (cur->ns == ns))
ret->application = xmlNodeListGetString(doc, cur->childs, 1);
ret->application = xmlNodeListGetString(doc, cur->childs, 1);
if ((!strcmp(cur->name, "Category")) &amp;&amp; (cur->ns == ns))
ret->category = xmlNodeListGetString(doc, cur->childs, 1);
ret->category = xmlNodeListGetString(doc, cur->childs, 1);
if ((!strcmp(cur->name, "Contact")) &amp;&amp; (cur->ns == ns))
ret->contact = parsePerson(doc, ns, cur);
cur = cur->next;
ret->contact = parsePerson(doc, ns, cur);
cur = cur->next;
}
return(ret);
}
</pre>
<p>
One can notice that once used to it, writing this kind of code
is quite simple, but boring. Ultimately, it could be possble to write
stubbers taking either C data structure definitions, a set of XML examples
or an XML DTD and produce the code needed to import and export the
content between C data and XML storage. This is left as an exercise to
the reader :-)</p>
<p>
Feel free to use <a href="gjobread.c">the code for the full C parsing
example</a> as a template,
}</pre>
<a href="mailto:Daniel.Veillard@w3.org">Daniel Veillard</a>
<p>One can notice that once used to it, writing this kind of code is quite
simple, but boring. Ultimately, it could be possble to write stubbers taking
either C data structure definitions, a set of XML examples or an XML DTD and
produce the code needed to import and export the content between C data and
XML storage. This is left as an exercise to the reader :-)</p>
<p>Feel free to use <a href="gjobread.c">the code for the full C parsing
example</a> as a template,</p>
<p> <a href="mailto:Daniel.Veillard@w3.org">Daniel Veillard</a></p>
</body>
</html>

View File

@ -23,7 +23,13 @@
#include <string.h>
#include <stdio.h>
#include "encoding.h"
#ifdef HAVE_UNICODE_H
#include <unicode.h>
#endif
#ifdef HAVE_UNICODE_H
#else /* ! HAVE_UNICODE_H */
/*
* From rfc2044: encoding of the Unicode values on UTF-8:
*
@ -206,6 +212,7 @@ UTF8ToUTF16(unsigned short* out, int outlen, unsigned char* in, int inlen)
return out-outstart;
}
#endif /* ! HAVE_UNICODE_H */
/**
* xmlDetectCharEncoding:
@ -407,8 +414,11 @@ xmlInitCharEncodingHandlers(void) {
return;
}
xmlNewCharEncodingHandler("UTF-8", NULL, NULL);
#ifdef HAVE_UNICODE_H
#else
xmlNewCharEncodingHandler("UTF-16", UTF16ToUTF8, UTF8ToUTF16);
xmlNewCharEncodingHandler("ISO-8859-1", isolat1ToUTF8, UTF8Toisolat1);
#endif
}
/**

View File

@ -68,7 +68,17 @@ xmlAddEntity(xmlEntitiesTablePtr table, const CHAR *name, int type,
* The entity is already defined in this Dtd, the spec says to NOT
* override it ... Is it worth a Warning ??? !!!
*/
return;
if (((type == XML_INTERNAL_PARAMETER_ENTITY) ||
(type == XML_EXTERNAL_PARAMETER_ENTITY)) &&
((cur->type == XML_INTERNAL_PARAMETER_ENTITY) ||
(cur->type == XML_EXTERNAL_PARAMETER_ENTITY)))
return;
else
if (((type != XML_INTERNAL_PARAMETER_ENTITY) &&
(type != XML_EXTERNAL_PARAMETER_ENTITY)) &&
((cur->type != XML_INTERNAL_PARAMETER_ENTITY) &&
(cur->type != XML_EXTERNAL_PARAMETER_ENTITY)))
return;
}
}
if (table->nb_entities >= table->max_entities) {
@ -78,9 +88,9 @@ xmlAddEntity(xmlEntitiesTablePtr table, const CHAR *name, int type,
table->max_entities *= 2;
table->table = (xmlEntityPtr)
realloc(table->table, table->max_entities * sizeof(xmlEntity));
if (table->table) {
if (table->table == NULL) {
perror("realloc failed");
exit(1);
return;
}
}
cur = &table->table[table->nb_entities];
@ -218,6 +228,43 @@ xmlAddDocEntity(xmlDocPtr doc, const CHAR *name, int type,
xmlAddEntity(table, name, type, ExternalID, SystemID, content);
}
/**
* xmlGetParameterEntity:
* @doc: the document referencing the entity
* @name: the entity name
*
* Do an entity lookup in the internal and external subsets and
* returns the corresponding parameter entity, if found.
*
* Returns A pointer to the entity structure or NULL if not found.
*/
xmlEntityPtr
xmlGetParameterEntity(xmlDocPtr doc, const CHAR *name) {
int i;
xmlEntityPtr cur;
xmlEntitiesTablePtr table;
if ((doc->intSubset != NULL) && (doc->intSubset->entities != NULL)) {
table = (xmlEntitiesTablePtr) doc->intSubset->entities;
for (i = 0;i < table->nb_entities;i++) {
cur = &table->table[i];
if (((cur->type == XML_INTERNAL_PARAMETER_ENTITY) ||
(cur->type == XML_EXTERNAL_PARAMETER_ENTITY)) &&
(!xmlStrcmp(cur->name, name))) return(cur);
}
}
if ((doc->extSubset != NULL) && (doc->extSubset->entities != NULL)) {
table = (xmlEntitiesTablePtr) doc->extSubset->entities;
for (i = 0;i < table->nb_entities;i++) {
cur = &table->table[i];
if (((cur->type == XML_INTERNAL_PARAMETER_ENTITY) ||
(cur->type == XML_EXTERNAL_PARAMETER_ENTITY)) &&
(!xmlStrcmp(cur->name, name))) return(cur);
}
}
return(NULL);
}
/**
* xmlGetDtdEntity:
* @doc: the document referencing the entity
@ -238,7 +285,9 @@ xmlGetDtdEntity(xmlDocPtr doc, const CHAR *name) {
table = (xmlEntitiesTablePtr) doc->extSubset->entities;
for (i = 0;i < table->nb_entities;i++) {
cur = &table->table[i];
if (!xmlStrcmp(cur->name, name)) return(cur);
if ((cur->type != XML_INTERNAL_PARAMETER_ENTITY) &&
(cur->type != XML_EXTERNAL_PARAMETER_ENTITY) &&
(!xmlStrcmp(cur->name, name))) return(cur);
}
}
return(NULL);
@ -265,7 +314,9 @@ xmlGetDocEntity(xmlDocPtr doc, const CHAR *name) {
table = (xmlEntitiesTablePtr) doc->intSubset->entities;
for (i = 0;i < table->nb_entities;i++) {
cur = &table->table[i];
if (!xmlStrcmp(cur->name, name)) return(cur);
if ((cur->type != XML_INTERNAL_PARAMETER_ENTITY) &&
(cur->type != XML_EXTERNAL_PARAMETER_ENTITY) &&
(!xmlStrcmp(cur->name, name))) return(cur);
}
}
if (xmlPredefinedEntities == NULL)
@ -273,7 +324,9 @@ xmlGetDocEntity(xmlDocPtr doc, const CHAR *name) {
table = xmlPredefinedEntities;
for (i = 0;i < table->nb_entities;i++) {
cur = &table->table[i];
if (!xmlStrcmp(cur->name, name)) return(cur);
if ((cur->type != XML_INTERNAL_PARAMETER_ENTITY) &&
(cur->type != XML_EXTERNAL_PARAMETER_ENTITY) &&
(!xmlStrcmp(cur->name, name))) return(cur);
}
return(NULL);
@ -291,8 +344,7 @@ xmlGetDocEntity(xmlDocPtr doc, const CHAR *name) {
/*
* A buffer used for converting entities to their equivalent and back.
*
* TODO: remove this, this helps performances but forbid reentrancy in a
* stupid way.
* TODO: remove this, once we are not afraid of breaking binary compatibility
*/
static int buffer_size = 0;
static CHAR *buffer = NULL;
@ -315,13 +367,10 @@ void growBuffer(void) {
* Do a global encoding of a string, replacing the predefined entities
* and non ASCII values with their entities and CharRef counterparts.
*
* TODO !!!! Once moved to UTF-8 internal encoding, the encoding of non-ascii
* get erroneous.
*
* TODO This routine is not reentrant, the interface
* should not be modified though.
* TODO: remove this, once we are not afraid of breaking binary compatibility
*
* People must migrate their code to xmlEncodeEntitiesReentrant !
* This routine will issue a warning when encountered.
*
* Returns A newly allocated string with the substitution done.
*/
@ -329,6 +378,13 @@ const CHAR *
xmlEncodeEntities(xmlDocPtr doc, const CHAR *input) {
const CHAR *cur = input;
CHAR *out = buffer;
static int warning = 1;
if (warning) {
fprintf(stderr, "Deprecated API xmlEncodeEntities() used\n");
fprintf(stderr, " change code to use xmlEncodeEntitiesReentrant()\n");
warning = 0;
}
if (input == NULL) return(NULL);
if (buffer == NULL) {

View File

@ -66,6 +66,7 @@ void xmlAddDtdEntity(xmlDocPtr doc, const CHAR *name, int type,
xmlEntityPtr xmlGetPredefinedEntity(const CHAR *name);
xmlEntityPtr xmlGetDocEntity(xmlDocPtr doc, const CHAR *name);
xmlEntityPtr xmlGetDtdEntity(xmlDocPtr doc, const CHAR *name);
xmlEntityPtr xmlGetParameterEntity(xmlDocPtr doc, const CHAR *name);
const CHAR *xmlEncodeEntities(xmlDocPtr doc, const CHAR *input);
CHAR *xmlEncodeEntitiesReentrant(xmlDocPtr doc, const CHAR *input);
xmlEntitiesTablePtr xmlCreateEntitiesTable(void);

175
error.c
View File

@ -10,35 +10,24 @@
#include <stdarg.h>
#include "parser.h"
/**
* xmlParserError:
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
*
* Display and format an error messages, gives file, line, position and
* extra parameters.
*/
void
xmlParserError(void *ctx, const char *msg, ...)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
static void
xmlParserPrintFileInfo(xmlParserInputPtr input) {
if (input != NULL) {
if (input->filename)
fprintf(stderr, "%s:%d: ", input->filename,
input->line);
else
fprintf(stderr, "line %d: ", input->line);
}
}
static void
xmlParserPrintFileContext(xmlParserInputPtr input) {
const CHAR *cur, *base;
va_list args;
int n;
va_start(args, msg);
if (ctxt->input->filename)
fprintf(stderr, "%s:%d: ", ctxt->input->filename,
ctxt->input->line);
else
fprintf(stderr, "line %d: ", ctxt->input->line);
fprintf(stderr, "error: ");
vfprintf(stderr, msg, args);
va_end(args);
cur = ctxt->input->cur;
base = ctxt->input->base;
cur = input->cur;
base = input->base;
while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
cur--;
}
@ -53,7 +42,7 @@ xmlParserError(void *ctx, const char *msg, ...)
n++;
}
fprintf(stderr, "\n");
cur = ctxt->input->cur;
cur = input->cur;
while ((*cur == '\n') || (*cur == '\r'))
cur--;
n = 0;
@ -64,6 +53,36 @@ xmlParserError(void *ctx, const char *msg, ...)
fprintf(stderr,"^\n");
}
/**
* xmlParserError:
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
*
* Display and format an error messages, gives file, line, position and
* extra parameters.
*/
void
xmlParserError(void *ctx, const char *msg, ...)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlParserInputPtr input;
va_list args;
input = ctxt->input;
if ((input->filename == NULL) && (ctxt->inputNr > 1))
input = ctxt->inputTab[ctxt->inputNr - 2];
xmlParserPrintFileInfo(input);
fprintf(stderr, "error: ");
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
xmlParserPrintFileContext(input);
}
/**
* xmlParserWarning:
* @ctx: an XML parser context
@ -77,44 +96,80 @@ void
xmlParserWarning(void *ctx, const char *msg, ...)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
const CHAR *cur, *base;
xmlParserInputPtr input;
va_list args;
int n;
va_start(args, msg);
if (ctxt->input->filename)
fprintf(stderr, "%s:%d: ", ctxt->input->filename,
ctxt->input->line);
else
fprintf(stderr, "line %d: ", ctxt->input->line);
input = ctxt->input;
if ((input->filename == NULL) && (ctxt->inputNr > 1))
input = ctxt->inputTab[ctxt->inputNr - 2];
xmlParserPrintFileInfo(input);
fprintf(stderr, "warning: ");
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
cur = ctxt->input->cur;
base = ctxt->input->base;
while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
cur--;
}
n = 0;
while ((n++ < 80) && (cur > base) && (*cur != '\n') && (*cur != '\r'))
cur--;
if ((*cur == '\n') || (*cur == '\r')) cur++;
base = cur;
n = 0;
while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
fprintf(stderr, "%c", (unsigned char) *cur++);
n++;
}
fprintf(stderr, "\n");
cur = ctxt->input->cur;
while ((*cur == '\n') || (*cur == '\r'))
cur--;
n = 0;
while ((cur != base) && (n++ < 80)) {
fprintf(stderr, " ");
base++;
}
fprintf(stderr,"^\n");
xmlParserPrintFileContext(input);
}
/**
* xmlParserValidityError:
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
*
* Display and format an validity error messages, gives file,
* line, position and extra parameters.
*/
void
xmlParserValidityError(void *ctx, const char *msg, ...)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlParserInputPtr input;
va_list args;
input = ctxt->input;
if ((input->filename == NULL) && (ctxt->inputNr > 1))
input = ctxt->inputTab[ctxt->inputNr - 2];
xmlParserPrintFileInfo(input);
fprintf(stderr, "validity error: ");
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
xmlParserPrintFileContext(input);
}
/**
* xmlParserValidityWarning:
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
*
* Display and format a validity warning messages, gives file, line,
* position and extra parameters.
*/
void
xmlParserValidityWarning(void *ctx, const char *msg, ...)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlParserInputPtr input;
va_list args;
input = ctxt->input;
if ((input->filename == NULL) && (ctxt->inputNr > 1))
input = ctxt->inputTab[ctxt->inputNr - 2];
xmlParserPrintFileInfo(input);
fprintf(stderr, "validity warning: ");
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
xmlParserPrintFileContext(input);
}

View File

@ -66,6 +66,7 @@ void xmlAddDtdEntity(xmlDocPtr doc, const CHAR *name, int type,
xmlEntityPtr xmlGetPredefinedEntity(const CHAR *name);
xmlEntityPtr xmlGetDocEntity(xmlDocPtr doc, const CHAR *name);
xmlEntityPtr xmlGetDtdEntity(xmlDocPtr doc, const CHAR *name);
xmlEntityPtr xmlGetParameterEntity(xmlDocPtr doc, const CHAR *name);
const CHAR *xmlEncodeEntities(xmlDocPtr doc, const CHAR *input);
CHAR *xmlEncodeEntitiesReentrant(xmlDocPtr doc, const CHAR *input);
xmlEntitiesTablePtr xmlCreateEntitiesTable(void);

View File

@ -1,5 +1,5 @@
/*
* parser.h : constants and stuff related to the XML parser.
* parser.h : Interfaces, constants and types related to the XML parser.
*
* See Copyright for the status of this software.
*
@ -10,6 +10,7 @@
#define __XML_PARSER_H__
#include "tree.h"
#include "valid.h"
#include "xmlIO.h"
#ifdef __cplusplus
@ -21,12 +22,22 @@ extern "C" {
*/
#define XML_DEFAULT_VERSION "1.0"
/**
* an xmlParserInput is an input flow for the XML processor.
* Each entity parsed is associated an xmlParserInput (except the
* few predefined ones). This is the case both for internal entities
* - in which case the flow is already completely in memory - or
* external entities - in which case we use the buf structure for
* progressive reading and I18N conversions to the internal UTF-8 format.
*/
typedef void (* xmlParserInputDeallocate)(CHAR *);
typedef struct xmlParserInput {
/* Input buffer */
xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
const char *filename; /* The file analyzed, if any */
const char *directory; /* the directory/base of teh file */
const CHAR *base; /* Base of the array to parse */
const CHAR *cur; /* Current char being parsed */
int line; /* Current line */
@ -36,6 +47,11 @@ typedef struct xmlParserInput {
} xmlParserInput;
typedef xmlParserInput *xmlParserInputPtr;
/**
* the parser can be asked to collect Node informations, i.e. at what
* place in the file they were detected.
* NOTE: This is off by default and not very well tested.
*/
typedef struct _xmlParserNodeInfo {
const struct xmlNode* node;
/* Position & line # that text that created the node begins & ends on */
@ -54,24 +70,63 @@ typedef struct xmlParserNodeInfoSeq {
typedef _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
/**
* The parser is not a state based parser, but we need to maintain
* minimum state informations, especially for entities processing.
*/
typedef enum xmlParserInputState {
XML_PARSER_EOF = 0,
XML_PARSER_PROLOG,
XML_PARSER_CONTENT,
XML_PARSER_ENTITY_DECL,
XML_PARSER_ENTITY_VALUE,
XML_PARSER_ATTRIBUTE_VALUE,
XML_PARSER_DTD,
XML_PARSER_EPILOG,
XML_PARSER_COMMENT,
XML_PARSER_CDATA_SECTION,
} xmlParserInputState;
/**
* The parser context.
* NOTE This doesn't completely defines the parser state, the (current ?)
* design of the parser uses recursive function calls since this allow
* and easy mapping from the production rules of the specification
* to the actual code. The drawback is that the actual function call
* also reflect the parser state. However most of the parsing routines
* takes as the only argument the parser context pointer, so migrating
* to a state based parser for progressive parsing shouldn't be too hard.
*/
typedef struct _xmlParserCtxt {
struct xmlSAXHandler *sax; /* The SAX handler */
void *userData; /* the document being built */
xmlDocPtr myDoc; /* the document being built */
int wellFormed; /* is the document well formed */
int replaceEntities; /* shall we replace entities ? */
const CHAR *version; /* the XML version string */
const CHAR *encoding; /* encoding, if any */
int standalone; /* standalone document */
int html; /* are we parsing an HTML document */
const CHAR *version; /* the XML version string */
const CHAR *encoding; /* encoding, if any */
int standalone; /* standalone document */
int hasExternalSubset; /* reference and external subset */
int hasPErefs; /* the internal subset has PE refs */
int html; /* are we parsing an HTML document */
int external; /* are we parsing an external entity */
int wellFormed; /* is the document well formed */
int valid; /* is the document valid */
int validate; /* shall we try to validate ? */
xmlValidCtxt vctxt; /* The validity context */
xmlParserInputState instate; /* current type of input */
int token; /* next char look-ahead */
char *directory; /* the data directory */
/* Input stream stack */
xmlParserInputPtr input; /* Current input stream */
int inputNr; /* Number of current input streams */
int inputMax; /* Max number of input streams */
xmlParserInputPtr *inputTab; /* stack of inputs */
/* Node analysis stack */
/* Node analysis stack only used for DOM building */
xmlNodePtr node; /* Current parsed Node */
int nodeNr; /* Depth of the parsing stack */
int nodeMax; /* Max depth of the parsing stack */
@ -83,10 +138,9 @@ typedef struct _xmlParserCtxt {
typedef _xmlParserCtxt xmlParserCtxt;
typedef xmlParserCtxt *xmlParserCtxtPtr;
/*
/**
* a SAX Locator.
*/
typedef struct xmlSAXLocator {
const CHAR *(*getPublicId)(void *ctx);
const CHAR *(*getSystemId)(void *ctx);
@ -96,8 +150,9 @@ typedef struct xmlSAXLocator {
typedef _xmlSAXLocator xmlSAXLocator;
typedef xmlSAXLocator *xmlSAXLocatorPtr;
/*
* a SAX Exception.
/**
* a SAX handler is bunch of callbacks called by the parser when processing
* of the input generate data or structure informations.
*/
#include "entities.h"
@ -108,6 +163,8 @@ typedef void (*internalSubsetSAXFunc) (void *ctx, const CHAR *name,
const CHAR *ExternalID, const CHAR *SystemID);
typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
const CHAR *name);
typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
const CHAR *name);
typedef void (*entityDeclSAXFunc) (void *ctx,
const CHAR *name, int type, const CHAR *publicId,
const CHAR *systemId, CHAR *content);
@ -138,6 +195,7 @@ typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
typedef void (*processingInstructionSAXFunc) (void *ctx,
const CHAR *target, const CHAR *data);
typedef void (*commentSAXFunc) (void *ctx, const CHAR *value);
typedef void (*cdataBlockSAXFunc) (void *ctx, const CHAR *value, int len);
typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
@ -170,12 +228,13 @@ typedef struct xmlSAXHandler {
warningSAXFunc warning;
errorSAXFunc error;
fatalErrorSAXFunc fatalError;
getParameterEntitySAXFunc getParameterEntity;
cdataBlockSAXFunc cdataBlock;
} xmlSAXHandler;
typedef xmlSAXHandler *xmlSAXHandlerPtr;
/*
* Global variables: just the SAX interface tables we are looking for full
* reentrancy of the code and version infos.
/**
* Global variables: just the default SAX interface tables and XML version infos.
*/
extern const char *xmlParserVersion;
@ -186,14 +245,14 @@ extern xmlSAXHandler htmlDefaultSAXHandler;
#include "entities.h"
#include "xml-error.h"
/*
/**
* Input functions
*/
int xmlParserInputRead(xmlParserInputPtr in, int len);
int xmlParserInputGrow(xmlParserInputPtr in, int len);
/*
/**
* CHAR handling
*/
CHAR *xmlStrdup(const CHAR *cur);
@ -207,23 +266,23 @@ int xmlStrlen(const CHAR *str);
CHAR *xmlStrcat(CHAR *cur, const CHAR *add);
CHAR *xmlStrncat(CHAR *cur, const CHAR *add, int len);
/*
* Interfaces
/**
* Basic parsing Interfaces
*/
xmlDocPtr xmlParseDoc(CHAR *cur);
xmlDocPtr xmlParseMemory(char *buffer, int size);
xmlDocPtr xmlParseFile(const char *filename);
int xmlSubstituteEntitiesDefault(int val);
/*
/**
* Recovery mode
*/
xmlDocPtr xmlRecoverDoc(CHAR *cur);
xmlDocPtr xmlRecoverMemory(char *buffer, int size);
xmlDocPtr xmlRecoverFile(const char *filename);
/*
* Internal routines
/**
* Less common routines and SAX interfaces
*/
int xmlParseDocument(xmlParserCtxtPtr ctxt);
xmlDocPtr xmlSAXParseDoc(xmlSAXHandlerPtr sax, CHAR *cur, int recovery);

View File

@ -18,6 +18,26 @@ extern "C" {
/**
* A few macros needed to help building the parser.
*/
/* #define UNICODE */
#ifdef UNICODE
typedef unsigned long CHARVAL;
#define NEXTCHARVAL(p) (unsigned long) \
((*(p) == 0) ? (unsigned long) 0 : \
((*(p) < 0x80) ? (unsigned long) (*(p)++) : \
(*(p) < 0xC0) ? (unsigned long) 0 : \
(*(p) < 0xE0) ? ((((unsigned long) *(p)++) << 6) + (*(p)++ & 0x3F)) : \
(*(p) < 0xF0) ? (((((unsigned long) *(p)++) << 6) + (*(p)++ & 0x3F)) << 6 + \
(*(p)++ & 0x3F)) : \
(*(p) < 0xF8) ? ((((((unsigned long) *(p)++) << 6) + (*(p)++ & 0x3F)) << 6 + \
(*(p)++ & 0x3F)) << 6 + (*(p)++ & 0x3F)) : 0))
#else
typedef unsigned char CHARVAL;
#define NEXTCHARVAL(p) (unsigned long) *(p);
#define SKIPCHARVAL(p) (p)++;
#endif
#ifdef UNICODE
/************************************************************************
@ -402,7 +422,6 @@ extern "C" {
#define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))
#else
#ifndef USE_UTF_8
/************************************************************************
* *
* 8bits / ISO-Latin version of the macros. *
@ -453,15 +472,6 @@ extern "C" {
*/
#define IS_EXTENDER(c) ((c) == 0xb7)
#else /* USE_UTF_8 */
/************************************************************************
* *
* 8bits / UTF-8 version of the macros. *
* *
************************************************************************/
TODO !!!
#endif /* USE_UTF_8 */
#endif /* !UNICODE */
/*
@ -513,6 +523,10 @@ xmlParserCtxtPtr
xmlCreateMemoryParserCtxt(char *buffer, int size);
void
xmlFreeParserCtxt(xmlParserCtxtPtr ctxt);
xmlParserCtxtPtr
xmlNewParserCtxt();
void
xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc);
/**
* Entities
@ -554,6 +568,8 @@ xmlParseNamespace(xmlParserCtxtPtr ctxt);
* Generic production rules
*/
CHAR *
xmlScanName(xmlParserCtxtPtr ctxt);
CHAR *
xmlParseName(xmlParserCtxtPtr ctxt);
CHAR *
xmlParseNmtoken(xmlParserCtxtPtr ctxt);
@ -638,6 +654,9 @@ void
xmlParseXMLDecl(xmlParserCtxtPtr ctxt);
void
xmlParseMisc(xmlParserCtxtPtr ctxt);
void
xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const CHAR *ExternalID,
const CHAR *SystemID);
/*
* Entities substitution

View File

@ -97,6 +97,7 @@ typedef xmlEnumeration *xmlEnumerationPtr;
typedef struct xmlAttribute {
const CHAR *elem; /* Element holding the attribute */
const CHAR *name; /* Attribute name */
struct xmlAttribute *next; /* list of attributes of an element */
xmlAttributeType type; /* The type */
xmlAttributeDefault def; /* the default */
const CHAR *defaultValue;/* or the default value */
@ -138,9 +139,10 @@ typedef enum {
} xmlElementTypeVal;
typedef struct xmlElement {
const CHAR *name; /* Element name */
xmlElementTypeVal type; /* The type */
const CHAR *name; /* Element name */
xmlElementTypeVal type; /* The type */
xmlElementContentPtr content; /* the allowed element content */
xmlAttributePtr attributes; /* List of the declared attributes */
} xmlElement;
typedef xmlElement *xmlElementPtr;
@ -188,7 +190,7 @@ typedef struct xmlAttr {
#endif
xmlElementType type; /* XML_ATTRIBUTE_NODE, must be third ! */
struct xmlNode *node; /* attr->node link */
struct xmlAttr *next; /* parent->childs link */
struct xmlAttr *next; /* attribute list link */
const CHAR *name; /* the name of the property */
struct xmlNode *val; /* the value of the property */
} xmlAttr;
@ -310,6 +312,7 @@ xmlNodePtr xmlNewDocTextLen(xmlDocPtr doc, const CHAR *content, int len);
xmlNodePtr xmlNewTextLen(const CHAR *content, int len);
xmlNodePtr xmlNewDocComment(xmlDocPtr doc, const CHAR *content);
xmlNodePtr xmlNewComment(const CHAR *content);
xmlNodePtr xmlNewCDataBlock(xmlDocPtr doc, const CHAR *content, int len);
xmlNodePtr xmlNewReference(xmlDocPtr doc, const CHAR *name);
xmlNodePtr xmlCopyNode(xmlNodePtr node, int recursive);
xmlNodePtr xmlCopyNodeList(xmlNodePtr node);

View File

@ -11,6 +11,22 @@
#define __XML_VALID_H__
#include "tree.h"
/**
* an xmlValidCtxt is used for error reporting when validating
*/
typedef void (*xmlValidityErrorFunc) (void *ctx, const char *msg, ...);
typedef void (*xmlValidityWarningFunc) (void *ctx, const char *msg, ...);
typedef struct xmlValidCtxt {
void *userData; /* user specific data block */
xmlValidityErrorFunc error; /* the callback in case of errors */
xmlValidityWarningFunc warning; /* the callback in case of warning */
} xmlValidCtxt, *xmlValidCtxtPtr;
extern void xmlParserValidityError(void *ctx, const char *msg, ...);
extern void xmlParserValidityWarning(void *ctx, const char *msg, ...);
/*
* ALl notation declarations are stored in a table
* there is one table per DTD
@ -21,7 +37,7 @@
typedef struct xmlNotationTable {
int nb_notations; /* number of notations stored */
int max_notations; /* maximum number of notations */
xmlNotationPtr table; /* the table of attributes */
xmlNotationPtr *table; /* the table of attributes */
} xmlNotationTable;
typedef xmlNotationTable *xmlNotationTablePtr;
@ -35,7 +51,7 @@ typedef xmlNotationTable *xmlNotationTablePtr;
typedef struct xmlElementTable {
int nb_elements; /* number of elements stored */
int max_elements; /* maximum number of elements */
xmlElementPtr table; /* the table of elements */
xmlElementPtr *table; /* the table of elements */
} xmlElementTable;
typedef xmlElementTable *xmlElementTablePtr;
@ -49,13 +65,13 @@ typedef xmlElementTable *xmlElementTablePtr;
typedef struct xmlAttributeTable {
int nb_attributes; /* number of attributes stored */
int max_attributes; /* maximum number of attributes */
xmlAttributePtr table; /* the table of attributes */
xmlAttributePtr *table; /* the table of attributes */
} xmlAttributeTable;
typedef xmlAttributeTable *xmlAttributeTablePtr;
/* Notation */
xmlNotationPtr xmlAddNotationDecl(xmlDtdPtr dtd, const CHAR *name,
const CHAR *PublicID, const CHAR *SystemID);
xmlNotationPtr xmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd,
const CHAR *name, const CHAR *PublicID, const CHAR *SystemID);
xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table);
void xmlFreeNotationTable(xmlNotationTablePtr table);
void xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table);
@ -66,8 +82,8 @@ xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
void xmlFreeElementContent(xmlElementContentPtr cur);
/* Element */
xmlElementPtr xmlAddElementDecl(xmlDtdPtr dtd, const CHAR *name, int type,
xmlElementContentPtr content);
xmlElementPtr xmlAddElementDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd,
const CHAR *name, int type, xmlElementContentPtr content);
xmlElementTablePtr xmlCopyElementTable(xmlElementTablePtr table);
void xmlFreeElementTable(xmlElementTablePtr table);
void xmlDumpElementTable(xmlBufferPtr buf, xmlElementTablePtr table);
@ -78,11 +94,32 @@ void xmlFreeEnumeration(xmlEnumerationPtr cur);
xmlEnumerationPtr xmlCopyEnumeration(xmlEnumerationPtr cur);
/* Attribute */
xmlAttributePtr xmlAddAttributeDecl(xmlDtdPtr dtd, const CHAR *elem,
const CHAR *name, int type, int def,
xmlAttributePtr xmlAddAttributeDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd,
const CHAR *elem, const CHAR *name, int type, int def,
const CHAR *defaultValue, xmlEnumerationPtr tree);
xmlAttributeTablePtr xmlCopyAttributeTable(xmlAttributeTablePtr table);
void xmlFreeAttributeTable(xmlAttributeTablePtr table);
void xmlDumpAttributeTable(xmlBufferPtr buf, xmlAttributeTablePtr table);
/**
* The public function calls related to validity checking
*/
int xmlValidateRoot(xmlValidCtxtPtr ctxt, xmlDocPtr doc);
int xmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
xmlElementPtr elem);
int xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
xmlAttributePtr attr);
int xmlValidateNotationDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
xmlNotationPtr nota);
int xmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd);
int xmlValidateDocument(xmlValidCtxtPtr ctxt, xmlDocPtr doc);
int xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem);
int xmlValidateOneElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
xmlNodePtr elem);
int xmlValidateOneAttribute(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
xmlNodePtr elem, xmlAttrPtr attr, const CHAR *value);
int xmlIsMixedElement(xmlDocPtr doc, const CHAR *name);
#endif /* __XML_VALID_H__ */

View File

@ -45,6 +45,7 @@ int xmlParserInputBufferRead(xmlParserInputBufferPtr in, int len);
int xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len);
void xmlFreeParserInputBuffer(xmlParserInputBufferPtr in);
char *xmlParserGetDirectory(const char *filename);
#ifdef __cplusplus
}

View File

@ -12,6 +12,7 @@ Copyright: LGPL
Group: X11/Libraries
Source: ftp://ftp.gnome.org/pub/GNOME/sources/libxml/libxml-%{ver}.tar.gz
BuildRoot: /var/tmp/libxml-%{PACKAGE_VERSION}-root
Provides: libxml.so.0
URL: http://www.gnome.org
Prereq: /sbin/install-info
@ -76,6 +77,14 @@ fi
rm -rf $RPM_BUILD_ROOT
make prefix=$RPM_BUILD_ROOT%{prefix} install
#
# hack to get libxml.so.0 too !
# Get rid of it once deps to libxml.so.0 have disapeared.
#
if [ -f $RPM_BUILD_ROOT/%{prefix}/lib/libxml.so.@VERSION@ ]
then
(cd $RPM_BUILD_ROOT/%{prefix}/lib/ ; cp libxml.so.@VERSION@ libxml.so.0.99.0 ; ln -sf libxml.so.0.99.0 libxml.so.0)
fi
%clean
@ -97,5 +106,4 @@ rm -rf $RPM_BUILD_ROOT
%{prefix}/lib/lib*.so
%{prefix}/lib/*a
%{prefix}/lib/*.sh
%{prefix}/include/*

1937
parser.c

File diff suppressed because it is too large Load Diff

101
parser.h
View File

@ -1,5 +1,5 @@
/*
* parser.h : constants and stuff related to the XML parser.
* parser.h : Interfaces, constants and types related to the XML parser.
*
* See Copyright for the status of this software.
*
@ -10,6 +10,7 @@
#define __XML_PARSER_H__
#include "tree.h"
#include "valid.h"
#include "xmlIO.h"
#ifdef __cplusplus
@ -21,12 +22,22 @@ extern "C" {
*/
#define XML_DEFAULT_VERSION "1.0"
/**
* an xmlParserInput is an input flow for the XML processor.
* Each entity parsed is associated an xmlParserInput (except the
* few predefined ones). This is the case both for internal entities
* - in which case the flow is already completely in memory - or
* external entities - in which case we use the buf structure for
* progressive reading and I18N conversions to the internal UTF-8 format.
*/
typedef void (* xmlParserInputDeallocate)(CHAR *);
typedef struct xmlParserInput {
/* Input buffer */
xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
const char *filename; /* The file analyzed, if any */
const char *directory; /* the directory/base of teh file */
const CHAR *base; /* Base of the array to parse */
const CHAR *cur; /* Current char being parsed */
int line; /* Current line */
@ -36,6 +47,11 @@ typedef struct xmlParserInput {
} xmlParserInput;
typedef xmlParserInput *xmlParserInputPtr;
/**
* the parser can be asked to collect Node informations, i.e. at what
* place in the file they were detected.
* NOTE: This is off by default and not very well tested.
*/
typedef struct _xmlParserNodeInfo {
const struct xmlNode* node;
/* Position & line # that text that created the node begins & ends on */
@ -54,24 +70,63 @@ typedef struct xmlParserNodeInfoSeq {
typedef _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
/**
* The parser is not a state based parser, but we need to maintain
* minimum state informations, especially for entities processing.
*/
typedef enum xmlParserInputState {
XML_PARSER_EOF = 0,
XML_PARSER_PROLOG,
XML_PARSER_CONTENT,
XML_PARSER_ENTITY_DECL,
XML_PARSER_ENTITY_VALUE,
XML_PARSER_ATTRIBUTE_VALUE,
XML_PARSER_DTD,
XML_PARSER_EPILOG,
XML_PARSER_COMMENT,
XML_PARSER_CDATA_SECTION,
} xmlParserInputState;
/**
* The parser context.
* NOTE This doesn't completely defines the parser state, the (current ?)
* design of the parser uses recursive function calls since this allow
* and easy mapping from the production rules of the specification
* to the actual code. The drawback is that the actual function call
* also reflect the parser state. However most of the parsing routines
* takes as the only argument the parser context pointer, so migrating
* to a state based parser for progressive parsing shouldn't be too hard.
*/
typedef struct _xmlParserCtxt {
struct xmlSAXHandler *sax; /* The SAX handler */
void *userData; /* the document being built */
xmlDocPtr myDoc; /* the document being built */
int wellFormed; /* is the document well formed */
int replaceEntities; /* shall we replace entities ? */
const CHAR *version; /* the XML version string */
const CHAR *encoding; /* encoding, if any */
int standalone; /* standalone document */
int html; /* are we parsing an HTML document */
const CHAR *version; /* the XML version string */
const CHAR *encoding; /* encoding, if any */
int standalone; /* standalone document */
int hasExternalSubset; /* reference and external subset */
int hasPErefs; /* the internal subset has PE refs */
int html; /* are we parsing an HTML document */
int external; /* are we parsing an external entity */
int wellFormed; /* is the document well formed */
int valid; /* is the document valid */
int validate; /* shall we try to validate ? */
xmlValidCtxt vctxt; /* The validity context */
xmlParserInputState instate; /* current type of input */
int token; /* next char look-ahead */
char *directory; /* the data directory */
/* Input stream stack */
xmlParserInputPtr input; /* Current input stream */
int inputNr; /* Number of current input streams */
int inputMax; /* Max number of input streams */
xmlParserInputPtr *inputTab; /* stack of inputs */
/* Node analysis stack */
/* Node analysis stack only used for DOM building */
xmlNodePtr node; /* Current parsed Node */
int nodeNr; /* Depth of the parsing stack */
int nodeMax; /* Max depth of the parsing stack */
@ -83,10 +138,9 @@ typedef struct _xmlParserCtxt {
typedef _xmlParserCtxt xmlParserCtxt;
typedef xmlParserCtxt *xmlParserCtxtPtr;
/*
/**
* a SAX Locator.
*/
typedef struct xmlSAXLocator {
const CHAR *(*getPublicId)(void *ctx);
const CHAR *(*getSystemId)(void *ctx);
@ -96,8 +150,9 @@ typedef struct xmlSAXLocator {
typedef _xmlSAXLocator xmlSAXLocator;
typedef xmlSAXLocator *xmlSAXLocatorPtr;
/*
* a SAX Exception.
/**
* a SAX handler is bunch of callbacks called by the parser when processing
* of the input generate data or structure informations.
*/
#include "entities.h"
@ -108,6 +163,8 @@ typedef void (*internalSubsetSAXFunc) (void *ctx, const CHAR *name,
const CHAR *ExternalID, const CHAR *SystemID);
typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
const CHAR *name);
typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
const CHAR *name);
typedef void (*entityDeclSAXFunc) (void *ctx,
const CHAR *name, int type, const CHAR *publicId,
const CHAR *systemId, CHAR *content);
@ -138,6 +195,7 @@ typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
typedef void (*processingInstructionSAXFunc) (void *ctx,
const CHAR *target, const CHAR *data);
typedef void (*commentSAXFunc) (void *ctx, const CHAR *value);
typedef void (*cdataBlockSAXFunc) (void *ctx, const CHAR *value, int len);
typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
@ -170,12 +228,13 @@ typedef struct xmlSAXHandler {
warningSAXFunc warning;
errorSAXFunc error;
fatalErrorSAXFunc fatalError;
getParameterEntitySAXFunc getParameterEntity;
cdataBlockSAXFunc cdataBlock;
} xmlSAXHandler;
typedef xmlSAXHandler *xmlSAXHandlerPtr;
/*
* Global variables: just the SAX interface tables we are looking for full
* reentrancy of the code and version infos.
/**
* Global variables: just the default SAX interface tables and XML version infos.
*/
extern const char *xmlParserVersion;
@ -186,14 +245,14 @@ extern xmlSAXHandler htmlDefaultSAXHandler;
#include "entities.h"
#include "xml-error.h"
/*
/**
* Input functions
*/
int xmlParserInputRead(xmlParserInputPtr in, int len);
int xmlParserInputGrow(xmlParserInputPtr in, int len);
/*
/**
* CHAR handling
*/
CHAR *xmlStrdup(const CHAR *cur);
@ -207,23 +266,23 @@ int xmlStrlen(const CHAR *str);
CHAR *xmlStrcat(CHAR *cur, const CHAR *add);
CHAR *xmlStrncat(CHAR *cur, const CHAR *add, int len);
/*
* Interfaces
/**
* Basic parsing Interfaces
*/
xmlDocPtr xmlParseDoc(CHAR *cur);
xmlDocPtr xmlParseMemory(char *buffer, int size);
xmlDocPtr xmlParseFile(const char *filename);
int xmlSubstituteEntitiesDefault(int val);
/*
/**
* Recovery mode
*/
xmlDocPtr xmlRecoverDoc(CHAR *cur);
xmlDocPtr xmlRecoverMemory(char *buffer, int size);
xmlDocPtr xmlRecoverFile(const char *filename);
/*
* Internal routines
/**
* Less common routines and SAX interfaces
*/
int xmlParseDocument(xmlParserCtxtPtr ctxt);
xmlDocPtr xmlSAXParseDoc(xmlSAXHandlerPtr sax, CHAR *cur, int recovery);

View File

@ -18,6 +18,26 @@ extern "C" {
/**
* A few macros needed to help building the parser.
*/
/* #define UNICODE */
#ifdef UNICODE
typedef unsigned long CHARVAL;
#define NEXTCHARVAL(p) (unsigned long) \
((*(p) == 0) ? (unsigned long) 0 : \
((*(p) < 0x80) ? (unsigned long) (*(p)++) : \
(*(p) < 0xC0) ? (unsigned long) 0 : \
(*(p) < 0xE0) ? ((((unsigned long) *(p)++) << 6) + (*(p)++ & 0x3F)) : \
(*(p) < 0xF0) ? (((((unsigned long) *(p)++) << 6) + (*(p)++ & 0x3F)) << 6 + \
(*(p)++ & 0x3F)) : \
(*(p) < 0xF8) ? ((((((unsigned long) *(p)++) << 6) + (*(p)++ & 0x3F)) << 6 + \
(*(p)++ & 0x3F)) << 6 + (*(p)++ & 0x3F)) : 0))
#else
typedef unsigned char CHARVAL;
#define NEXTCHARVAL(p) (unsigned long) *(p);
#define SKIPCHARVAL(p) (p)++;
#endif
#ifdef UNICODE
/************************************************************************
@ -402,7 +422,6 @@ extern "C" {
#define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))
#else
#ifndef USE_UTF_8
/************************************************************************
* *
* 8bits / ISO-Latin version of the macros. *
@ -453,15 +472,6 @@ extern "C" {
*/
#define IS_EXTENDER(c) ((c) == 0xb7)
#else /* USE_UTF_8 */
/************************************************************************
* *
* 8bits / UTF-8 version of the macros. *
* *
************************************************************************/
TODO !!!
#endif /* USE_UTF_8 */
#endif /* !UNICODE */
/*
@ -513,6 +523,10 @@ xmlParserCtxtPtr
xmlCreateMemoryParserCtxt(char *buffer, int size);
void
xmlFreeParserCtxt(xmlParserCtxtPtr ctxt);
xmlParserCtxtPtr
xmlNewParserCtxt();
void
xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc);
/**
* Entities
@ -554,6 +568,8 @@ xmlParseNamespace(xmlParserCtxtPtr ctxt);
* Generic production rules
*/
CHAR *
xmlScanName(xmlParserCtxtPtr ctxt);
CHAR *
xmlParseName(xmlParserCtxtPtr ctxt);
CHAR *
xmlParseNmtoken(xmlParserCtxtPtr ctxt);
@ -638,6 +654,9 @@ void
xmlParseXMLDecl(xmlParserCtxtPtr ctxt);
void
xmlParseMisc(xmlParserCtxtPtr ctxt);
void
xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const CHAR *ExternalID,
const CHAR *SystemID);
/*
* Entities substitution

View File

@ -1,5 +1,22 @@
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT EXAMPLE
ATTRIBUTE prop1
TEXT
content=gnome is great
ATTRIBUTE prop2
TEXT
content=& linux too
Object is a Node Set :
Set contains 6 nodes:
1 ELEMENT head
2 ELEMENT chapter
3 ELEMENT chapter
4 ELEMENT chapter
5 ELEMENT chapter
6 ELEMENT chapter
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT head
Object is a Node Set :
Set contains 6 nodes:

View File

@ -1,5 +1,17 @@
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT EXAMPLE
ATTRIBUTE prop1
TEXT
content=gnome is great
ATTRIBUTE prop2
TEXT
content=& linux too
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
Object is a Node Set :
Set contains 2 nodes:

View File

@ -1,5 +1,17 @@
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT EXAMPLE
ATTRIBUTE prop1
TEXT
content=gnome is great
ATTRIBUTE prop2
TEXT
content=& linux too
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT chapter
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT head
Object is a Node Set :
Set contains 2 nodes:

166
test/HTML/fp40.htm Normal file
View File

@ -0,0 +1,166 @@
<!doctype html public "-//IETF//DTD HTML//EN">
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<title>README - Microsoft FrontPage 2000 Server Extensions</title>
<meta name="Microsoft Theme" content="none">
</head>
<body>
<font face="Verdana">
<h1><a name="top">Microsoft FrontPage 2000 Server Extensions, UNIX</a></h1>
<font size="2"><i>© Copyright Microsoft Corporation, 1999&nbsp;</i></font>
<p>The FrontPage Server Extensions are a set of programs on the Web server that support:
<ul>
<li>Authoring FrontPage webs</li>
<li>Administering FrontPage webs</li>
<li>Browse-time FrontPage web functionality</li>
</ul>
<h2>Contents&nbsp;</h2>
<a href="#relnotes">Release Notes</a><br>
<a href="#moreinfo">Resources for More Information</a>
<p>&nbsp;</p>
<hr>
<h2><a name="relnotes">Release Notes</a></h2>
<p>This section provides complementary or late-breaking
information to supplement the Microsoft FrontPage Server Extensions documentation.</p>
<p><a href="#apache">Apache 1.3.4 Support</a><br>
<a href="#upgrading">Upgrading from previous version of FrontPage Server Extensions</a><br>
<a href="#executables">Uploading files into executable folders</a></p>
<p align="right"><font size="1"><a href="#top">Top of Page</a></font></p>
<h3><a name="apache">Apache 1.3.4 Support</a></h3>
<p>You need to take some special steps to run the FrontPage Server Extensions with Apache 1.3.4.
FrontPage Server Extensions expect to find all resource directives in the main server
configuration file, usually http.conf. To prevent the server extensions from using any secondary
configuration files (access.conf, srm.conf), add the following lines to http.conf:</p>
</font>
<blockquote>
<font face="Courier New">
ResourceConfig /dev/null&nbsp;<br>
AccessConfig /dev/null</font>
</blockquote>
<font face="Verdana">
<p>If you have some settings stored in secondary configuration files, move them to http.conf.</p>
<p>You must stop and restart the web server for your changes to http.conf to take effect.</p>
<p align="right"><font size="1"><a href="#relnotes">Top of Section</a></font></p>
<h3><a name="upgrading">Upgrading from previous version of FrontPage Server Extensions</a></h3>
<p>Custom entries in frontpage.cnf are not migrated to FrontPage 2000.</p>
<p>When you install FrontPage 2000 Server Extensions, a new frontpage.cnf file is created in the /usr/local/frontpage/version4.0 directory.
Any custom settings stored in a previous-version frontpage.cnf are not used. However, you can copy
your custom settings from the previous-version frontpage.cnf file after you install the FrontPage 2000 Server Extensions.</p>
<p>Do not overwrite the FrontPage 2000 frontpage.cnf file with a frontpage.cnf file from an
earlier version of the FrontPage Server Extensions.</p>
<p align="right"><font size="1"><a href="#relnotes">Top of Section</a></font></p>
<h3><a name="executables">Uploading files into executable folders</a></h3>
<p>After upgrading to FrontPage 2000, FrontPage authors will not be able to upload files into
executable folders. For security reasons, the default setting on FrontPage 2000 webs does not
allow authors to upload executable files into executable folders in a FrontPage web. This
setting protects servers so that authors do not inadvertently upload a program containing a bug
or a virus.</p>
<p>To allow FrontPage authors to upload executables, set the NoExecutableCgiUpload configuration
variable to zero (0). For information about FrontPage Server Extension configuration variables,
see the FrontPage 2000 Server Extensions Resource Kit at <a href="http://officeupdate.microsoft.com/frontpage/wpp/serk/">http://officeupdate.microsoft.com/frontpage/wpp/serk/</a>.</p>
<p align="right"><font size="1"><a href="#relnotes">Top of Section</a></font></p>
<hr>
<h2><a name="moreinfo">Resources for More Information</a></h2>
<p>This section lists sources of more information about the
FrontPage Server Extensions.</p>
<p><a href="#serk">Server Extensions Resource Kit</a><br>
<a href="#serkupdate">Server Extensions Resource Kit Update</a><br>
<a href="#kb">Knowledge Base</a></p>
<p align="right"><font size="1"><a href="#top">Top of Page</a></font></p>
<h3><a name="serk">Server Extensions Resource Kit</a></h3>
<p>The FrontPage 2000 Server Extensions include a full set of documentation: the Server
Extensions Resource Kit. This is an HTML document installed on the server machine (by
default) in /usr/local/frontpage/version4.0/serk. To view the Server Extensions Resource
Kit, open /usr/local/frontpage/version4.0/serk/default.htm in your Web browser.</p>
<p>The Server Extensions Resource Kit contains detailed information about installing and
administering the FrontPage Server Extensions along with an overview of the Server
Extensions, a detailed discussion of Server Extensions security on UNIX and Windows,
troubleshooting information, and a full set of appendixes.</p>
<p align="right"><font size="1"><a href="#moreinfo">Top of Section</a></font></p>
<h3><a name="serkupdate">Server Extensions Resource Kit Update</a></h3>
<p>For updated information about installing, setting up, and administrating the FrontPage Server
Extensions, see the Server Extensions Resource Kit Update at: <a href="http://officeupdate.microsoft.com/frontpage/wpp/serk/">http://officeupdate.microsoft.com/frontpage/wpp/serk/</a>.</p>
<p align="right"><font size="1"><a href="#moreinfo">Top of Section</a></font></p>
<h3><a name="kb">Microsoft Knowledge Base</a></h3>
<p>For further technical information on FrontPage, please consult Support Online. Use Support
Online to easily search Microsoft Product Support Services' collection of resources including
technical articles from Microsoft's extensive Knowledge Base, FAQs, & troubleshooters to find
fast, accurate answers. You can also customize the site to control your search using either
keywords or the site's natural language search engine, which uses normal everyday language for
answering inquiries, so you can write your question in your own words. To begin, go to
<a href="http://support.microsoft.com/support/">http://support.microsoft.com/support/</a>.</p>
<p align="right"><font size="1"><a href="#moreinfo">Top of Section</a></font></p>
<p>&nbsp;</p>
</font>
</body>
</html>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!DOCTYPE doc [
<!ELEMENT doc (#PCDATA)>
<!ATTLIST doc At NMTOKEN "$$$">
<!ATTLIST doc Ok NMTOKEN "1abc_2">
<!ATTLIST doc bad IDREF "1abc_2">
<!ATTLIST doc ok2 IDREF "abc_2">
<!ATTLIST doc bad2 IDREFS "abc:1 1abc_2">
<!ATTLIST doc ok3 IDREFS "abc:1 a1bc_2">
]>
<doc val="v1"/>

5
test/VC/DuplicateType Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE a [
<!ELEMENT a (#PCDATA | b | c | d | c)*>
]>
<a> violates [ VC: No Duplicate Types ] </a>

3
test/VC/ElementValid Normal file
View File

@ -0,0 +1,3 @@
<!DOCTYPE doc [
]>
<doc/>

4
test/VC/ElementValid2 Normal file
View File

@ -0,0 +1,4 @@
<!DOCTYPE doc [
<!ELEMENT doc (p)*>
]>
<doc><p/></doc>

4
test/VC/ElementValid3 Normal file
View File

@ -0,0 +1,4 @@
<!DOCTYPE doc [
<!ELEMENT doc EMPTY>
]>
<doc>Oops, this element was declared EMPTY</doc>

7
test/VC/ElementValid4 Normal file
View File

@ -0,0 +1,7 @@
<!DOCTYPE doc [
<!ELEMENT doc (#PCDATA | a | b)*>
<!ELEMENT a EMPTY>
<!ELEMENT b (#PCDATA)>
<!ELEMENT c (#PCDATA)>
]>
<doc> This <b>seems</b> Ok <a/> but this <c>was not declared</c></doc>

7
test/VC/ElementValid5 Normal file
View File

@ -0,0 +1,7 @@
<!DOCTYPE doc [
<!ELEMENT doc (a , b* , c+)>
<!ELEMENT a EMPTY>
<!ELEMENT b (#PCDATA)>
<!ELEMENT c (#PCDATA)>
]>
<doc><a/><b> but this</b><c>was not declared</c><b>seems</b></doc>

7
test/VC/ElementValid6 Normal file
View File

@ -0,0 +1,7 @@
<!DOCTYPE doc [
<!ELEMENT doc (a , b? , c+)?>
<!ELEMENT a EMPTY>
<!ELEMENT b (#PCDATA)>
<!ELEMENT c (#PCDATA)>
]>
<doc><a/><b>lacks c</b></doc>

7
test/VC/ElementValid7 Normal file
View File

@ -0,0 +1,7 @@
<!DOCTYPE doc [
<!ELEMENT doc ((a | b)* , c+, a, b?, c, a?)>
<!ELEMENT a EMPTY>
<!ELEMENT b (#PCDATA)>
<!ELEMENT c (#PCDATA)>
]>
<doc><a/><b/><a/><c/><c/><a/></doc>

5
test/VC/Enumeration Normal file
View File

@ -0,0 +1,5 @@
<!DOCTYPE doc [
<!ELEMENT doc (#PCDATA)>
<!ATTLIST doc val (v1 | v2 | v3) #IMPLIED>
]>
<doc val="v4"></doc>

6
test/VC/OneID Normal file
View File

@ -0,0 +1,6 @@
<!DOCTYPE doc [
<!ELEMENT doc (#PCDATA)>
<!ATTLIST doc val ID #IMPLIED>
<!ATTLIST doc id ID #IMPLIED>
]>
<doc val="v1"></doc>

6
test/VC/OneID2 Normal file
View File

@ -0,0 +1,6 @@
<!DOCTYPE doc [
<!ATTLIST doc val ID #IMPLIED>
<!ATTLIST doc id ID #IMPLIED>
<!ELEMENT doc (#PCDATA)>
]>
<doc val="v1"></doc>

4
test/VC/OneID3 Normal file
View File

@ -0,0 +1,4 @@
<!DOCTYPE doc SYSTEM "dtds/doc.dtd" [
<!ATTLIST doc id ID #IMPLIED>
]>
<doc val="v1"></doc>

2
test/VC/PENesting Normal file
View File

@ -0,0 +1,2 @@
<!ENTITY % pe1 "EMPTY> <!ELEMENT e2 EMPTY>">
<!ELEMENT e1 %pe1;

3
test/VC/PENesting2 Normal file
View File

@ -0,0 +1,3 @@
<!ENTITY % p1 "(A|B">
<!ENTITY % p2 "|C|D)">
<!ELEMENT X %p1;%p2;>

View File

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE a SYSTEM "dtds/a.dtd" [
<!ELEMENT a (#PCDATA | b | c)*>
<!ELEMENT b (#PCDATA)>
<!ELEMENT c (#PCDATA)>
]>
<a> violates [ VC: Unique Element Type Declaration ] </a>

View File

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!DOCTYPE a [
<!ELEMENT a (#PCDATA | b | c)*>
<!ELEMENT b (#PCDATA)>
<!ELEMENT c (#PCDATA)>
<!ELEMENT a (#PCDATA | b | c)*>
]>
<a> violates [ VC: Unique Element Type Declaration ] </a>

2
test/VC/dtds/a.dtd Normal file
View File

@ -0,0 +1,2 @@
<!ELEMENT a (#PCDATA | b | c)*>
<!ATTLIST doc id ID #IMPLIED>

2
test/VC/dtds/doc.dtd Normal file
View File

@ -0,0 +1,2 @@
<!ELEMENT doc (#PCDATA)>
<!ATTLIST doc val ID #IMPLIED>

2
test/WFC/ElemTypeMatch Normal file
View File

@ -0,0 +1,2 @@
<?xml version="1.0"?>
<a> violates [ WFC: Element Type Match ] </b>

2
test/WFC/EntityDeclared Normal file
View File

@ -0,0 +1,2 @@
<?xml version="1.0"?>
<a> &unknown; violates [ WFC: Entity Declared ] </a>

5
test/WFC/EntityDeclared2 Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE a [
<!ENTITY e "an entity">
]>
<a> &unknown; violates [ WFC: Entity Declared ] </a>

3
test/WFC/EntityDeclared3 Normal file
View File

@ -0,0 +1,3 @@
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE a SYSTEM "a.dtd">
<a> &unknown; violates [ WFC: Entity Declared ] </a>

6
test/WFC/EntityDeclared4 Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE a [
%unknown;
<!ENTITY % unknown "<!ELEMENT a (#PCDATA)>">
]>
<a> violates [ WFC: Entity Declared ] </a>

6
test/WFC/EntityDeclared5 Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE a SYSTEM "a.dtd" [
%unknown;
<!ENTITY % unknown "<!ELEMENT a (#PCDATA)>">
]>
<a> violates [ WFC: Entity Declared ] </a>

2
test/WFC/LegalCharacter Normal file
View File

@ -0,0 +1,2 @@
<?xml version="1.0"?>
<a> &#5; violates [ WFC: Legal Character ] </a>

View File

@ -0,0 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE a [
<!ENTITY ext SYSTEM "ext.ent">
]>
<a att="wrong &ext; ref"> violates [ WFC: No External Entity References ] </a>

5
test/WFC/NoLtInAttValue Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE a [
<!ENTITY ext "no < workie">
]>
<a att="wrong &ext; ref"> violates [ WFC: No < in Attribute Values ] </a>

7
test/WFC/NoRecursion Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE doc [
<!ENTITY a "&b;">
<!ENTITY b "&c;">
<!ENTITY c "&a;">
]>
<doc> &a; violates [ WFC: No Recursion ] </doc>

6
test/WFC/PEintsubset Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE a [
<!ENTITY % pcdata "(#PCDATA)">
<!ELEMENT e %pcdata>
]>
<a> violates [ WFC: PEs in Internal Subset ] </a>

2
test/WFC/UniqueAttSpec Normal file
View File

@ -0,0 +1,2 @@
<?xml version="1.0"?>
<a att="Ok" att2="Ok" att="Bad"> violates [ WFC: Unique Att Spec ] </a>

2
test/WFC/UniqueAttSpec2 Normal file
View File

@ -0,0 +1,2 @@
<?xml version="1.0"?>
<a> <b att="Ok" att2="Ok" att="Bad"/> violates [ WFC: Unique Att Spec ] </a>

View File

@ -1,7 +1,9 @@
/child::head
/child::*
/child::head/child::title
/child::head/child::title/child::text()
/child::head/node()
/child::EXAMPLE
/child::EXAMPLE/child::*
/child::EXAMPLE/child::head
/child::EXAMPLE/child::*
/child::EXAMPLE/child::head/child::title
/child::EXAMPLE/child::head/child::title/child::text()
/child::EXAMPLE/child::head/node()
/descendant::title
/descendant::p/ancestor::chapter

View File

@ -1,4 +1,6 @@
/chapter[1]
/EXAMPLE
/EXAMPLE/chapter
/EXAMPLE/chapter[1]
//p
//chapter/image
//p/text()

View File

@ -1,7 +1,9 @@
/child::head
/child::*
/child::head/child::title
/child::head/child::title/child::text()
/child::head/node()
/child::EXAMPLE
/child::EXAMPLE/child::chapter
/child::EXAMPLE/child::head
/child::EXAMPLE/child::*
/child::EXAMPLE/child::head/child::title
/child::EXAMPLE/child::head/child::title/child::text()
/child::EXAMPLE/child::head/node()
/descendant::title
/descendant::p/ancestor::chapter

3
test/cdata Normal file
View File

@ -0,0 +1,3 @@
<doc>
<![CDATA[<greeting>Hello, world!</greeting>]]>
</doc>

5
test/dtd12 Normal file
View File

@ -0,0 +1,5 @@
<!DOCTYPE doc [
<!ENTITY % YN '"Yes"' >
<!ENTITY WhatHeSaid "He said %YN;" >
]>
<doc>&WhatHeSaid;</doc>

4
test/dtds/eve.dtd Normal file
View File

@ -0,0 +1,4 @@
<!ENTITY % local.p.class "">
<!ENTITY % p.class "p
%local.p.class;">

8
test/ent6 Normal file
View File

@ -0,0 +1,8 @@
<!DOCTYPE doc [
<!ENTITY lt "&#38;#60;">
<!ENTITY gt "&#62;">
<!ENTITY amp "&#38;#38;">
<!ENTITY apos "&#39;">
<!ENTITY quot "&#34;">
]>
<doc></doc>

7
test/ent7 Normal file
View File

@ -0,0 +1,7 @@
<!DOCTYPE item [
<!ENTITY % sampleEnt "<!ELEMENT item (para)+>">
<!ENTITY sampleEnt "the hyacinth girl">
%sampleEnt;
<!ELEMENT para (#PCDATA)>
]>
<item><para>'they called me &sampleEnt;'</para></item>

6
test/errors/dtd13 Normal file
View File

@ -0,0 +1,6 @@
<!DOCTYPE doc [
<!ENTITY EndAttr "27'" >
]>
<doc>
<element attribute='a-&EndAttr;>
</doc>

6
test/eve.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE spec PUBLIC "-//testspec//" "dtds/eve.dtd" [
<!ENTITY iso6.doc.date '29-May-1999'>
]>
<spec>
</spec>

File diff suppressed because it is too large Load Diff

160
test/valid/dia.xml Normal file
View File

@ -0,0 +1,160 @@
<?xml version="1.0"?>
<!DOCTYPE diagram [
<!ELEMENT diagram (diagramdata, (layer)*) >
<!ELEMENT diagramdata (attribute)* >
<!ELEMENT layer (object | group)*>
<!ATTLIST layer
name CDATA #REQUIRED
visible (true|false) #REQUIRED >
<!ELEMENT object ((attribute)*, connections?)>
<!ATTLIST object
type CDATA #REQUIRED
version NMTOKEN #REQUIRED
id ID #REQUIRED >
<!ELEMENT connections (connection)*>
<!ELEMENT connection EMPTY>
<!ATTLIST connection
handle NMTOKEN #REQUIRED
to IDREF #REQUIRED
connection NMTOKEN #REQUIRED>
<!ELEMENT group (object | group)*>
<!ELEMENT attribute (composite | int | enum | real | boolean |
color | point | rectangle | string | font)*>
<!ATTLIST attribute name CDATA #REQUIRED >
<!ELEMENT composite (attribute)*>
<!ATTLIST composite type CDATA #IMPLIED>
<!ELEMENT int EMPTY>
<!ATTLIST int val NMTOKEN #REQUIRED>
<!ELEMENT enum EMPTY>
<!ATTLIST enum val NMTOKEN #REQUIRED>
<!ELEMENT real EMPTY>
<!ATTLIST real val CDATA #REQUIRED>
<!ELEMENT boolean EMPTY>
<!ATTLIST boolean val (true|false) #REQUIRED>
<!ELEMENT color EMPTY>
<!ATTLIST color val CDATA #REQUIRED>
<!ELEMENT point EMPTY>
<!ATTLIST point val CDATA #REQUIRED>
<!ELEMENT rectangle EMPTY>
<!ATTLIST rectangle val CDATA #REQUIRED>
<!ELEMENT string EMPTY>
<!ATTLIST string val CDATA #IMPLIED>
<!ELEMENT font EMPTY>
<!ATTLIST font name CDATA #REQUIRED>
]>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
<dia:diagramdata>
<dia:attribute name="background">
<dia:color val="#ffffff"/>
</dia:attribute>
</dia:diagramdata>
<dia:layer name="Background" visible="true">
<dia:object type="Standard - Line" version="0" id="O0">
<dia:attribute name="obj_pos">
<dia:point val="1.95,6.85"/>
</dia:attribute>
<dia:attribute name="obj_bb">
<dia:rectangle val="1.9,6.8;11,8.55"/>
</dia:attribute>
<dia:attribute name="conn_endpoints">
<dia:point val="1.95,6.85"/>
<dia:point val="10.95,8.5"/>
</dia:attribute>
<dia:attribute name="line_color">
<dia:color val="#000000"/>
</dia:attribute>
<dia:attribute name="line_width">
<dia:real val="0.1"/>
</dia:attribute>
<dia:attribute name="line_style">
<dia:enum val="0"/>
</dia:attribute>
<dia:attribute name="start_arrow">
<dia:enum val="0"/>
</dia:attribute>
<dia:attribute name="end_arrow">
<dia:enum val="0"/>
</dia:attribute>
<dia:connections>
<dia:connection handle="1" to="O2" connection="3"/>
</dia:connections>
</dia:object>
<dia:object type="Standard - Text" version="0" id="O1">
<dia:attribute name="obj_pos">
<dia:point val="4.8,4.75"/>
</dia:attribute>
<dia:attribute name="obj_bb">
<dia:rectangle val="2.579,3.96359;7.021,4.96359"/>
</dia:attribute>
<dia:attribute name="text">
<dia:composite type="text">
<dia:attribute name="string">
<dia:string val="sdfsdfg"/>
</dia:attribute>
<dia:attribute name="font">
<dia:font name="Courier"/>
</dia:attribute>
<dia:attribute name="height">
<dia:real val="1"/>
</dia:attribute>
<dia:attribute name="pos">
<dia:point val="4.8,4.75"/>
</dia:attribute>
<dia:attribute name="color">
<dia:color val="#000000"/>
</dia:attribute>
<dia:attribute name="alignment">
<dia:enum val="1"/>
</dia:attribute>
</dia:composite>
</dia:attribute>
</dia:object>
<dia:object type="Standard - Box" version="0" id="O2">
<dia:attribute name="obj_pos">
<dia:point val="10.95,7.5"/>
</dia:attribute>
<dia:attribute name="obj_bb">
<dia:rectangle val="10.9,7.45;13.05,9.55"/>
</dia:attribute>
<dia:attribute name="elem_corner">
<dia:point val="10.95,7.5"/>
</dia:attribute>
<dia:attribute name="elem_width">
<dia:real val="2.05"/>
</dia:attribute>
<dia:attribute name="elem_height">
<dia:real val="2"/>
</dia:attribute>
<dia:attribute name="border_width">
<dia:real val="0.1"/>
</dia:attribute>
<dia:attribute name="border_color">
<dia:color val="#000000"/>
</dia:attribute>
<dia:attribute name="inner_color">
<dia:color val="#ffffff"/>
</dia:attribute>
<dia:attribute name="line_style">
<dia:enum val="0"/>
</dia:attribute>
</dia:object>
</dia:layer>
</dia:diagram>

972
test/valid/dtds/spec.dtd Executable file
View File

@ -0,0 +1,972 @@
<!-- ............................................................... -->
<!-- XML specification DTD ......................................... -->
<!-- ............................................................... -->
<!--
TYPICAL INVOCATION:
# <!DOCTYPE spec PUBLIC
# "-//W3C//DTD Specification::19980323//EN"
# "http://www.w3.org/XML/Group/DTD/xmlspec.dtd">
PURPOSE:
This DTD was developed for use with the XML family of W3C
specifications. It is an XML-compliant DTD based in part on
the TEI Lite and Sweb DTDs.
DEPENDENCIES:
None.
CHANGE HISTORY:
The list of changes is at the end of the DTD.
For all details, see the design report at:
<http://www.w3.org/XML/Group/DTD/xmlspec-report.htm>
The "typical invocation" FPI always gets updated to reflect the
date of the most recent changes.
Search this file for "#" in the first column to see change history
comments.
MAINTAINER:
Eve Maler
ArborText Inc.
elm@arbortext.com
voice: +1 781 270 5750
fax: +1 781 273 3760
-->
<!-- ............................................................... -->
<!-- Entities for characters and symbols ........................... -->
<!--
#1998-03-10: maler: Added &ldquo; and &rdquo;.
# Used 8879:1986-compatible decimal character
# references.
# Merged charent.mod file back into main file.
-->
<!ENTITY lt "&#38;#60;">
<!ENTITY gt "&#62;">
<!ENTITY amp "&#38;#38;">
<!ENTITY apos "&#39;">
<!ENTITY quot "&#34;">
<!ENTITY mdash "--">
<!ENTITY nbsp "&#160;">
<!ENTITY ldquo "#x201C;">
<!ENTITY rdquo "#x201D;">
<!-- ............................................................... -->
<!-- Entities for classes of standalone elements ................... -->
<!--
#1997-10-16: maler: Added table to %illus.class;.
#1997-11-28: maler: Added htable to %illus.class;.
#1997-12-29: maler: IGNOREd table.
#1998-03-10: maler: Removed SGML Open-specific %illus.class;.
# Added "local" entities for customization.
-->
<!ENTITY % local.p.class "">
<!ENTITY % p.class "p
%local.p.class;">
<!ENTITY % local.statusp.class "">
<!ENTITY % statusp.class "statusp
%local.statusp.class;">
<!ENTITY % local.list.class "">
<!ENTITY % list.class "ulist|olist|slist|glist
%local.list.class;">
<!ENTITY % local.speclist.class "">
<!ENTITY % speclist.class "orglist|blist
%local.speclist.class;">
<!ENTITY % local.note.class "">
<!ENTITY % note.class "note|wfcnote|vcnote
%local.note.class;">
<!ENTITY % local.illus.class "">
<!ENTITY % illus.class "eg|graphic|scrap|htable
%local.illus.class;">
<!-- ............................................................... -->
<!-- Entities for classes of phrase-level elements ................. -->
<!--
#1997-12-29: maler: Added xspecref to %ref.class;.
#1998-03-10: maler: Added %ednote.class;.
# Added "local" entities for customization.
-->
<!ENTITY % local.annot.class "">
<!ENTITY % annot.class "footnote
%local.annot.class;">
<!ENTITY % local.termdef.class "">
<!ENTITY % termdef.class "termdef|term
%local.termdef.class;">
<!ENTITY % local.emph.class "">
<!ENTITY % emph.class "emph|quote
%local.emph.class;">
<!ENTITY % local.ref.class "">
<!ENTITY % ref.class "bibref|specref|termref|titleref
|xspecref|xtermref
%local.ref.class;">
<!ENTITY % local.loc.class "">
<!ENTITY % loc.class "loc
%local.loc.class;">
<!ENTITY % local.tech.class "">
<!ENTITY % tech.class "kw|nt|xnt|code
%local.tech.class;">
<!ENTITY % local.ednote.class "">
<!ENTITY % ednote.class "ednote
%local.ednote.class;">
<!-- ............................................................... -->
<!-- Entities for mixtures of standalone elements .................. -->
<!--
#1997-09-30: maler: Created %p.mix; to eliminate p from self.
#1997-09-30: maler: Added %speclist.class; to %obj.mix; and %p.mix;.
#1997-09-30: maler: Added %note.class; to %obj.mix; and %p.mix;.
#1997-10-16: maler: Created %entry.mix;. Note that some elements
# left out here are still allowed in termdef,
# which entry can contain through %p.pcd.mix;.
#1997-11-28: maler: Added %p.class; to %statusobj.mix;.
#1998-03-10: maler: Added %ednote.class; to all mixtures, except
# %p.mix; and %statusobj.mix;, because paragraphs
# and status paragraphs will contain ednote
# through %p.pcd.mix;.
#1998-03-123: maler: Added %termdef.mix; (broken out from
# %termdef.pcd.mix;).
-->
<!ENTITY % div.mix
"%p.class;|%list.class;|%speclist.class;|%note.class;
|%illus.class;|%ednote.class;">
<!ENTITY % obj.mix
"%p.class;|%list.class;|%speclist.class;|%note.class;
|%illus.class;|%ednote.class;">
<!ENTITY % p.mix
"%list.class;|%speclist.class;|%note.class;|%illus.class;">
<!ENTITY % entry.mix
"%list.class;|note|eg|graphic|%ednote.class;">
<!ENTITY % statusobj.mix
"%p.class;|%statusp.class;|%list.class;">
<!ENTITY % hdr.mix
"%p.class;|%list.class;|%ednote.class;">
<!ENTITY % termdef.mix
"%note.class;|%illus.class;">
<!-- ............................................................... -->
<!-- Entities for mixtures of #PCDATA and phrase-level elements .... -->
<!-- Note that %termdef.pcd.mix contains %note.class;
and %illus.class;, considered standalone elements. -->
<!--
#1997-09-30: maler: Added scrap and %note.class; to %termdef.pcd.mix;.
#1997-11-28: maler: Added %loc.class; to %p.pcd.mix;.
#1998-03-10: maler: Added %ednote.class; to all mixtures.
#1998-03-23: maler: Moved some %termdef.pcd.mix; stuff out to
# %termdef.mix;.
-->
<!ENTITY % p.pcd.mix
"#PCDATA|%annot.class;|%termdef.class;|%emph.class;
|%ref.class;|%tech.class;|%loc.class;|%ednote.class;">
<!ENTITY % statusp.pcd.mix
"#PCDATA|%annot.class;|%termdef.class;|%emph.class;
|%ref.class;|%tech.class;|%loc.class;|%ednote.class;">
<!ENTITY % head.pcd.mix
"#PCDATA|%annot.class;|%emph.class;|%tech.class;|%ednote.class;">
<!ENTITY % label.pcd.mix
"#PCDATA|%annot.class;|%termdef.class;|%emph.class;|%tech.class;
|%ednote.class;">
<!ENTITY % eg.pcd.mix
"#PCDATA|%annot.class;|%emph.class;|%ednote.class;">
<!ENTITY % termdef.pcd.mix
"#PCDATA|term|%emph.class;|%ref.class;|%tech.class;
|%ednote.class;">
<!ENTITY % bibl.pcd.mix
"#PCDATA|%emph.class;|%ref.class;|%loc.class;|%ednote.class;">
<!ENTITY % tech.pcd.mix
"#PCDATA|%ednote.class;">
<!ENTITY % loc.pcd.mix
"#PCDATA|%loc.class;|%ednote.class;">
<!-- ............................................................... -->
<!-- Entities for customizable content models ...................... -->
<!--
#1998-03-10: maler: Added customization entities.
-->
<!ENTITY % spec.mdl
"header, front?, body, back?">
<!ENTITY % header.mdl
"title, subtitle?, version, w3c-designation, w3c-doctype,
pubdate, notice*, publoc, latestloc?, prevlocs?, authlist,
abstract, status, pubstmt?, sourcedesc?, langusage,
revisiondesc">
<!ENTITY % pubdate.mdl
"day?, month, year">
<!-- ............................................................... -->
<!-- Entities for common attributes ................................ -->
<!-- key attribute:
Optionally provides a sorting or indexing key, for cases when
the element content is inappropriate for this purpose. -->
<!ENTITY % key.att
'key CDATA #IMPLIED'>
<!-- def attribute:
Points to the element where the relevant definition can be
found, using the IDREF mechanism. %def.att; is for optional
def attributes, and %def-req.att; is for required def
attributes. -->
<!ENTITY % def.att
'def IDREF #IMPLIED'>
<!ENTITY % def-req.att
'def IDREF #REQUIRED'>
<!-- ref attribute:
Points to the element where more information can be found,
using the IDREF mechanism. %ref.att; is for optional
ref attributes, and %ref-req.att; is for required ref
attributes. -->
<!ENTITY % ref.att
'ref IDREF #IMPLIED'>
<!ENTITY % ref-req.att
'ref IDREF #REQUIRED'>
<!--
#1998-03-23: maler: Added show and actuate attributes to href.
# Added semi-common xml:space attribute.
-->
<!-- HREF and source attributes:
Points to the element where more information or source data
can be found, using the URL (XLL simple link) mechanism.
For some purposes, is associated with additional XLL
attributes. %href.att; is for optional HREF attributes,
and %href-req.att; is for required HREF attributes.
%source-req.att; is for the source attribute, which
is always required. -->
<!ENTITY % href.att
'xml-link CDATA #FIXED "simple"
href CDATA #IMPLIED
show CDATA #FIXED "embed"
actuate CDATA #FIXED "auto"'>
<!ENTITY % href-req.att
'xml-link CDATA #FIXED "simple"
href CDATA #REQUIRED
show CDATA #FIXED "embed"
actuate CDATA #FIXED "auto"'>
<!ENTITY % source-req.att
'xml-link CDATA #FIXED "simple"
xml:attributes NMTOKENS #FIXED "href source"
source CDATA #REQUIRED
show CDATA #FIXED "embed"
actuate CDATA #FIXED "auto"'>
<!-- xml:space attribute:
Indicates that the element contains white space
that the formatter or other application should retain,
as appropriate to its function. -->
<!ENTITY % xmlspace.att
'xml:space (default
|preserve) #FIXED "preserve"'>
<!-- Common attributes:
Every element has an ID attribute (sometimes required,
but usually optional) for links, and a Role attribute
for extending the useful life of the DTD by allowing
authors to make subclasses for any element. %common.att;
is for common attributes where the ID is optional, and
%common-idreq.att; is for common attributes where the
ID is required. -->
<!ENTITY % common.att
'id ID #IMPLIED
role NMTOKEN #IMPLIED'>
<!ENTITY % common-idreq.att
'id ID #REQUIRED
role NMTOKEN #IMPLIED'>
<!-- ............................................................... -->
<!-- Common elements ............................................... -->
<!-- head: Title on divisions, productions, and the like -->
<!ELEMENT head (%head.pcd.mix;)*>
<!ATTLIST head %common.att;>
<!-- ............................................................... -->
<!-- Major specification structure ................................. -->
<!--
#1998-03-10: maler: Made spec content model easily customizable.
-->
<!ELEMENT spec (%spec.mdl;)>
<!ATTLIST spec %common.att;>
<!ELEMENT front (div1+)>
<!ATTLIST front %common.att;>
<!ELEMENT body (div1+)>
<!ATTLIST body %common.att;>
<!--
#1997-09-30: maler: Added inform-div1 to back content.
-->
<!ELEMENT back ((div1+, inform-div1*) | inform-div1+)>
<!ATTLIST back %common.att;>
<!ELEMENT div1 (head, (%div.mix;)*, div2*)>
<!ATTLIST div1 %common.att;>
<!--
#1997-09-30: maler: Added inform-div1 declarations.
-->
<!-- inform-div1: Non-normative division in back matter -->
<!ELEMENT inform-div1 (head, (%div.mix;)*, div2*)>
<!ATTLIST inform-div1 %common.att;>
<!ELEMENT div2 (head, (%div.mix;)*, div3*)>
<!ATTLIST div2 %common.att;>
<!ELEMENT div3 (head, (%div.mix;)*, div4*)>
<!ATTLIST div3 %common.att;>
<!ELEMENT div4 (head, (%div.mix;)*)>
<!ATTLIST div4 %common.att;>
<!-- Specification header .......... -->
<!--
#1998-03-10: maler: Made header content model easily customizable.
-->
<!ELEMENT header (%header.mdl;)>
<!ATTLIST header %common.att;>
<!-- Example of title: "Extensible Cheese Language (XCL)" -->
<!ELEMENT title (#PCDATA)>
<!ATTLIST title %common.att;>
<!-- Example of subtitle: "A Cheesy Specification" -->
<!ELEMENT subtitle (#PCDATA)>
<!ATTLIST subtitle %common.att;>
<!-- Example of version: "Version 666.0" -->
<!ELEMENT version (#PCDATA)>
<!ATTLIST version %common.att;>
<!-- Example of w3c-designation: "WD-xcl-19991231" -->
<!ELEMENT w3c-designation (#PCDATA)>
<!ATTLIST w3c-designation %common.att;>
<!-- Example of w3c-doctype: "World Wide Web Consortium Working
Draft" -->
<!ELEMENT w3c-doctype (#PCDATA)>
<!ATTLIST w3c-doctype %common.att;>
<!--
#1998-03-10: maler: Made pubdate content model easily customizable.
-->
<!ELEMENT pubdate (%pubdate.mdl;)>
<!ATTLIST pubdate %common.att;>
<!ELEMENT day (#PCDATA)>
<!ATTLIST day %common.att;>
<!ELEMENT month (#PCDATA)>
<!ATTLIST month %common.att;>
<!ELEMENT year (#PCDATA)>
<!ATTLIST year %common.att;>
<!-- Example of notice: "This draft is for public comment..." -->
<!ELEMENT notice (%hdr.mix;)+>
<!ATTLIST notice %common.att;>
<!ELEMENT publoc (loc+)>
<!ATTLIST publoc %common.att;>
<!ELEMENT prevlocs (loc+)>
<!ATTLIST prevlocs %common.att;>
<!ELEMENT latestloc (loc+)>
<!ATTLIST latestloc %common.att;>
<!-- loc (defined in "Phrase-level elements" below) -->
<!ELEMENT authlist (author+)>
<!ATTLIST authlist %common.att;>
<!--
#1997-09-30: maler: Made affiliation optional.
#1998-03-10: maler: Made email optional.
-->
<!ELEMENT author (name, affiliation?, email?)>
<!ATTLIST author %common.att;>
<!ELEMENT name (#PCDATA)>
<!ATTLIST name
%common.att;
%key.att;>
<!ELEMENT affiliation (#PCDATA)>
<!ATTLIST affiliation %common.att;>
<!ELEMENT email (#PCDATA)>
<!-- HREF attribute:
email functions as a hypertext reference through this
required attribute. Typically the reference would use
the mailto: scheme. -->
<!ATTLIST email
%common.att;
%href-req.att;>
<!-- The status element now contains both statusp and p, and
the latter now allows loc. Use p; statusp will be removed
eventually. -->
<!ELEMENT status (%statusobj.mix;)+>
<!ATTLIST status %common.att;>
<!ELEMENT abstract (%hdr.mix;)*>
<!ATTLIST abstract %common.att;>
<!ELEMENT pubstmt (%hdr.mix;)+>
<!ATTLIST pubstmt %common.att;>
<!ELEMENT sourcedesc (%hdr.mix;)+>
<!ATTLIST sourcedesc %common.att;>
<!ELEMENT langusage (language+)>
<!ATTLIST langusage %common.att;>
<!ELEMENT language (#PCDATA)>
<!ATTLIST language %common.att;>
<!ELEMENT revisiondesc (%hdr.mix;)+>
<!ATTLIST revisiondesc %common.att;>
<!-- ............................................................... -->
<!-- Standalone elements ........................................... -->
<!-- Paragraphs .................... -->
<!--
#1997-09-30: maler: Changed from %obj.mix; to %p.mix;.
#1997-12-29: maler: Changed order of %p.mix; and %p.pcd.mix; references.
#1997-12-29: maler: Changed order of %statusobj.mix; and %statusp.pcd.mix;
# references.
-->
<!ELEMENT p (%p.pcd.mix;|%p.mix;)*>
<!ATTLIST p %common.att;>
<!-- statusp: Special paragraph that allows loc inside it (note that
p now also allows loc) -->
<!ELEMENT statusp (%statusp.pcd.mix;|%statusobj.mix;)*>
<!ATTLIST statusp %common.att;>
<!-- Lists ......................... -->
<!ELEMENT ulist (item+)>
<!-- spacing attribute:
Use "normal" to get normal vertical spacing for items;
use "compact" to get less spacing. The default is dependent
on the stylesheet. -->
<!ATTLIST ulist
%common.att;
spacing (normal|compact) #IMPLIED>
<!ELEMENT olist (item+)>
<!-- spacing attribute:
Use "normal" to get normal vertical spacing for items;
use "compact" to get less spacing. The default is dependent
on the stylesheet. -->
<!ATTLIST olist
%common.att;
spacing (normal|compact) #IMPLIED>
<!ELEMENT item (%obj.mix;)+>
<!ATTLIST item %common.att;>
<!ELEMENT slist (sitem+)>
<!ATTLIST slist %common.att;>
<!ELEMENT sitem (%p.pcd.mix;)*>
<!ATTLIST sitem %common.att;>
<!ELEMENT glist (gitem+)>
<!ATTLIST glist %common.att;>
<!ELEMENT gitem (label, def)>
<!ATTLIST gitem %common.att;>
<!ELEMENT label (%label.pcd.mix;)*>
<!ATTLIST label %common.att;>
<!ELEMENT def (%obj.mix;)*>
<!ATTLIST def %common.att;>
<!-- Special lists ................. -->
<!ELEMENT blist (bibl+)>
<!ATTLIST blist %common.att;>
<!ELEMENT bibl (%bibl.pcd.mix;)*>
<!-- HREF attribute:
bibl optionally functions as a hypertext reference to the
referred-to resource through this attribute. -->
<!ATTLIST bibl
%common.att;
%href.att;
%key.att;>
<!ELEMENT orglist (member+)>
<!ATTLIST orglist %common.att;>
<!--
#1997-09-30: maler: Added optional affiliation.
-->
<!ELEMENT member (name, affiliation?, role?)>
<!ATTLIST member %common.att;>
<!-- name (defined in "Specification header" above) -->
<!-- affiliation (defined in "Specification header" above) -->
<!ELEMENT role (#PCDATA)>
<!ATTLIST role %common.att;>
<!-- Notes ......................... -->
<!ELEMENT note (%obj.mix;)+>
<!ATTLIST note %common.att;>
<!ELEMENT wfcnote (head, (%obj.mix;)+)>
<!-- ID attribute:
wfcnote must have an ID so that it can be pointed to
from a wfc element in a production. -->
<!ATTLIST wfcnote
%common-idreq.att;>
<!ELEMENT vcnote (head, (%obj.mix;)+)>
<!-- ID attribute:
vcnote must have an ID so that it can be pointed to
from a vc element in a production. -->
<!ATTLIST vcnote
%common-idreq.att;>
<!-- Illustrations ................. -->
<!--
#1998-03-23: maler: Added xml:space attribute.
-->
<!ELEMENT eg (%eg.pcd.mix;)*>
<!ATTLIST eg
%common.att;
%xmlspace.att;>
<!ELEMENT graphic EMPTY>
<!-- source attribute:
The graphic data must reside at the location pointed to.
This is a hypertext reference, but for practical purposes,
for now it should just be a pathname. -->
<!ATTLIST graphic
%common.att;
%source-req.att;
alt CDATA #IMPLIED>
<!--
#1997-11-28: maler: Added prodgroup to scrap and defined it.
-->
<!ELEMENT scrap (head, (prodgroup+ | prod+ | bnf))>
<!-- lang attribute:
The scrap can link to a description of the language used,
found in a language element in the header. -->
<!ATTLIST scrap
%common.att;
lang IDREF #IMPLIED>
<!ELEMENT prodgroup (prod+)>
<!-- pcw<n> attributes:
Presentational attributes to control the width
of the "pseudo-table" columns used to output
groups of productions. -->
<!ATTLIST prodgroup
%common.att;
pcw1 CDATA #IMPLIED
pcw2 CDATA #IMPLIED
pcw3 CDATA #IMPLIED
pcw4 CDATA #IMPLIED
pcw5 CDATA #IMPLIED
>
<!ELEMENT prod (lhs, (rhs, (com|wfc|vc)*)+)>
<!-- ID attribute:
The production must have an ID so that cross-references
(specref) and mentions of nonterminals (nt) can link to
it. -->
<!ATTLIST prod
%common-idreq.att;>
<!ELEMENT lhs (#PCDATA)>
<!ATTLIST lhs %common.att;>
<!ELEMENT rhs (#PCDATA|nt|xnt|com)*>
<!ATTLIST rhs %common.att;>
<!-- nt and xnt (defined in "Phrase-level elements" below) -->
<!--
#1997-11-28: maler: Added loc and bibref to com content.
-->
<!ELEMENT com (#PCDATA|loc|bibref)*>
<!ATTLIST com %common.att;>
<!-- wfc: Should generate the head of the wfcnote pointed to -->
<!ELEMENT wfc EMPTY>
<!-- def attribute:
Each well formedness tagline in a production must link to the
wfcnote that defines it. -->
<!ATTLIST wfc
%def-req.att;
%common.att;>
<!-- vc: Should generate the head of the vcnote pointed to -->
<!ELEMENT vc EMPTY>
<!-- def attribute:
Each validity tagline in a production must link to the vcnote
that defines it. -->
<!ATTLIST vc
%def-req.att;
%common.att;>
<!--
#1998-03-23: maler: Added xml:space attribute.
-->
<!-- bnf: Un-marked-up production -->
<!ELEMENT bnf (%eg.pcd.mix;)*>
<!ATTLIST bnf
%common.att;
%xmlspace.att;>
<!--
#1997-10-16: maler: Added table mechanism.
#1997-11-28: maler: Added non-null system ID to entity declaration.
# Added HTML table module.
#1997-12-29: maler: IGNOREd SGML Open table model.
#1998-03-10: maler: Removed SGML Open table model.
# Merged html-tbl.mod file into main file.
# Added %common.att; to all HTML table elements.
-->
<!-- TR and TD attributes:
Alignment attributes. No default. -->
<!ENTITY % trtd.att
"align (left
|center
|right) #IMPLIED
valign (top
|middle
|bottom) #IMPLIED">
<!ELEMENT htable (htbody+)>
<!ATTLIST htable
border CDATA "0"
cellpadding CDATA "0"
align (left
|center
|right) "left">
<!ELEMENT htbody (tr+)>
<!ATTLIST htbody %common.att;>
<!ELEMENT tr (td+)>
<!ATTLIST tr
%common.att;
%trtd.att;>
<!ELEMENT td (%p.pcd.mix;)*>
<!ATTLIST td
%common.att;
%trtd.att;
bgcolor CDATA #IMPLIED
rowspan CDATA "1"
colspan CDATA "1">
<!-- ............................................................... -->
<!-- Phrase-level elements ......................................... -->
<!-- bibref: Should generate, in square brackets, "key" on bibl -->
<!ELEMENT bibref EMPTY>
<!-- ref attribute:
A bibliography reference must link to the bibl element that
describes the resource. -->
<!ATTLIST bibref
%common.att;
%ref-req.att;>
<!ELEMENT code (%tech.pcd.mix;)*>
<!ATTLIST code %common.att;>
<!--
#1998-03-10: maler: Declared ednote and related elements.
-->
<!ELEMENT ednote (name?, date?, edtext)>
<!ATTLIST ednote %common.att;>
<!ELEMENT date (#PCDATA)>
<!ATTLIST date %common.att;>
<!ELEMENT edtext (#PCDATA)>
<!ATTLIST edtext %common.att;>
<!ELEMENT emph (#PCDATA)>
<!ATTLIST emph %common.att;>
<!-- footnote: Both footnote content and call to footnote -->
<!ELEMENT footnote (%obj.mix;)+>
<!ATTLIST footnote %common.att;>
<!ELEMENT kw (%tech.pcd.mix;)*>
<!ATTLIST kw %common.att;>
<!ELEMENT loc (#PCDATA)>
<!-- HREF attribute:
The purpose of a loc element is to function as a hypertext
link to a resource. (Ideally, the content of loc will also
mention the URI of the resource, so that readers of the
printed version will be able to locate the resource.) -->
<!ATTLIST loc
%common.att;
%href-req.att;>
<!ELEMENT nt (#PCDATA)>
<!-- def attribute:
The nonterminal must link to the production that defines
it. -->
<!ATTLIST nt
%common.att;
%def-req.att;>
<!--
#1998-03-10: maler: Declared quote.
-->
<!-- quote: Scare quotes and other purely presentational quotes -->
<!ELEMENT quote (%p.pcd.mix;)*>
<!ATTLIST quote %common.att;>
<!-- specref: Should generate italic "[n.n], Section Title" for
div, "n" for numbered item, or "[n]" for production -->
<!ELEMENT specref EMPTY>
<!-- ref attribute:
The purpose of a specref element is to link to a div, item
in an olist, or production in the current spec. -->
<!ATTLIST specref
%common.att;
%ref-req.att;>
<!ELEMENT term (#PCDATA)>
<!ATTLIST term %common.att;>
<!ELEMENT termdef (%termdef.pcd.mix;|%termdef.mix;)*>
<!-- ID attribute:
A term definition must have an ID so that it can be linked
to from termref elements. -->
<!-- term attribute:
The canonical form of the term or phrase being defined must
appear in this attribute, even if the term or phrase also
appears in the element content in identical form (e.g., in
the term element). -->
<!ATTLIST termdef
%common-idreq.att;
term CDATA #REQUIRED>
<!ELEMENT termref (#PCDATA)>
<!-- ref attribute:
A term reference must link to the termdef element that
defines the term. -->
<!ATTLIST termref
%common.att;
%def-req.att;>
<!ELEMENT titleref (#PCDATA)>
<!-- HREF attribute:
A title reference can optionally function as a hypertext
link to the resource with this title. -->
<!ATTLIST titleref
%common.att;
%href.att;>
<!ELEMENT xnt (#PCDATA)>
<!-- HREF attribute:
The nonterminal must hyperlink to a resource that serves
to define it (e.g., a production in a related XML
specification). -->
<!ATTLIST xnt
%common.att;
%href-req.att;>
<!--
#1997-12-29: maler: Declared xspecref.
-->
<!ELEMENT xspecref (#PCDATA)>
<!-- HREF attribute:
The spec reference must hyperlink to the resource to
cross-refer to (e.g., a section in a related XML
specification). -->
<!ATTLIST xspecref
%common.att;
%href-req.att;>
<!ELEMENT xtermref (#PCDATA)>
<!-- HREF attribute:
The term reference must hyperlink to the resource that
serves to define the term (e.g., a term definition in
a related XML specification). -->
<!ATTLIST xtermref
%common.att;
%href-req.att;>
<!-- ............................................................... -->
<!-- Unused elements for ADEPT ..................................... -->
<!--
#1997-09-30: maler: Added unusued elements.
#1997-10-14: maler: Fixed div to move nested div to the mixture.
-->
<!-- The following elements are purposely declared but never
referenced. Declaring them allows them to be pasted from
an HTML document into a document using this DTD in ADEPT.
The ATD Context Transformation mechanism will try to convert
them to the appropriate element for this DTD. While this
conversion will not work for all fragments, it does allow
many cases to work reasonably well. -->
<!ELEMENT div
(head?, (%div.mix;|ul|ol|h1|h2|h3|h4|h5|h6|div)*)>
<!ELEMENT h1 (%head.pcd.mix;|em|a)*>
<!ELEMENT h2 (%head.pcd.mix;|em|a)*>
<!ELEMENT h3 (%head.pcd.mix;|em|a)*>
<!ELEMENT h4 (%head.pcd.mix;|em|a)*>
<!ELEMENT h5 (%head.pcd.mix;|em|a)*>
<!ELEMENT h6 (%head.pcd.mix;|em|a)*>
<!ELEMENT pre (%eg.pcd.mix;|em)*>
<!ELEMENT ul (item|li)*>
<!ELEMENT ol (item|li)*>
<!ELEMENT li (#PCDATA|%obj.mix;)*>
<!ELEMENT em (#PCDATA)>
<!ELEMENT a (#PCDATA)>
<!-- ............................................................... -->
<!-- Change history ................................................ -->
<!--
#1997-08-18: maler
#- Did a major revision.
#1997-09-10: maler
#- Updated FPI.
#- Removed namekey element and put key attribute on name element.
#- Made statusp element and supporting entities.
#- Added slist element with sitem+ content.
#- Required head on scrap and added new bnf subelement.
#- Added an xnt element and allowed it and nt in regular text and rhs.
#- Removed the ntref element.
#- Added back the com element to the content of rhs.
#- Added a key attribute to bibl.
#- Removed the ident element.
#- Added a term element to be used inside termdef.
#- Added an xtermref element parallel to termref.
#- Beefed up DTD comments.
#1997-09-12: maler
#- Allowed term element in general text.
#- Changed bibref to EMPTY.
#- Added ref.class to termdef.pcd.mix.
#1997-09-14: maler
#- Changed main attribute of xtermref from def to href.
#- Added termdef.class to label contents.
#1997-09-30: maler
#- Added character entity module and added new entities.
#- Removed p from appearing directly in self; created %p.mix;.
#- Added inform-div (non-normative division) element.
#- Fixed xtermref comment to mention HREF, not ref.
#- Extended orglist model to allow optional affiliation.
#- Modified author to make affiliation optional.
#- Added %speclist.class; and %note.class; to %obj.mix; and %p.mix;.
#- Added %note.class; and %illus.class; to %termdef.pcd.mix;.
#- Added unused HTML elements.
#- Put empty system ID next to public ID in entity declarations.
#1997-10-14: maler
#- Fixed "unused" div content model to move nested div to mixture.
#1997-10-16: maler
#- Added SGML Open Exchange tables.
#1997-11-28: maler
#- Added support for prodgroup and its attributes.
#- Added support for HTML tables.
#- Added loc and bibref to content of com.
#- Added loc to general p content models.
#- Allowed p as alternative to statusp in status.
#- Added non-null system IDs to external parameter entity declarations.
#- (Modified the SGML Open table module to make it XML-compliant.)
#- (Modified the character entity module.)
#1997-12-29: maler
#- Moved #PCDATA occurrences to come before GIs in content models.
#- Removed use of the SGML Open table module.
#- Added xspecref element.
#- Ensured that all FPIs contain 4-digit year.
#- (Modified the character entity module.)
#1997-03-10: maler
#- Merged the character entity and table modules into the main file.
#- Added ldquo and rdquo entities.
#- Added common attributes to prodgroup.
#- Made the email element in header optional.
#- Removed reference to the SGML Open table model.
#- Added ednote element.
#- Added quote element.
#- Updated XLink usage to reflect 3 March 1998 WD.
#- Added "local" entities to the class entities for customization.
#- Parameterized several content models to allow for customization.
#1997-03-23: maler
#- Cleaned up some comments and removed some others.
#- Added xml:space semi-common attribute to eg and bnf elements.
#- Added show and embed attributes on all the uses of href.
#- Added %common.att; to all HTML table elements.
#- Added a real URI to the "typical invocation" comment.
-->
<!-- ............................................................... -->
<!-- End of XML specification DTD .................................. -->
<!-- ............................................................... -->

1102
test/valid/dtds/xmlspec.dtd Normal file

File diff suppressed because it is too large Load Diff

529
test/valid/xlink.xml Normal file
View File

@ -0,0 +1,529 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE spec PUBLIC "-//W3C//DTD Specification::19990205//EN" "dtds/xmlspec.dtd" [
<!ENTITY doc-type "WD">
<!ENTITY iso6.doc.date '29-May-1999'>
]>
<!--ArborText, Inc., 1988-1998, v.4002-->
<?Pub UDT _bookmark _target?>
<?Pub Inc?>
<?xml-stylesheet
href="file:///C|/Program%20Files/SoftQuad/XMetaL%201/display/xmlspec.css"
type="text/css"?>
<spec>
<!-- Last edited: 27 May 1999 by bent -->
<header><?Pub Dtl?>
<title>XML Linking Language (XLink)</title>
<version>Version 1.0</version>
<w3c-designation><!-- &doc-type;-&iso6.doc.date; --> WD-xlink-19990527</w3c-designation>
<w3c-doctype>World Wide Web Consortium Working Draft</w3c-doctype>
<pubdate><day>29</day><month>May</month><year>1999</year></pubdate>
<notice>
<p>This draft is for public discussion.</p>
</notice>
<publoc><loc href="http://www.w3.org/XML/Group/1999/05/WD-xlink-current">http://www.w3.org/XML/Group/1999/05/WD-xlink-current</loc></publoc>
<prevlocs>
<!--Check: was it actually August?-->
<loc href="http://www.w3.org/XML/Group/1999/05/WD-xlink-19990527">http://www.w3.org/XML/Group/1999/05/WD-xlink-19990527</loc>
<loc href="http://www.w3.org/XML/Group/1999/05/WD-xlink-19990505">http://www.w3.org/XML/Group/1999/05/WD-xlink-19990505</loc>
<loc href="http://www.w3.org/TR/1998/WD-xlink-19980303">http://www.w3.org/TR/1998/WD-xlink-19980303</loc>
<loc href="http://www.w3.org/TR/WD-xml-link-970630">http://www.w3.org/TR/WD-xml-link-970630</loc></prevlocs>
<authlist>
<!--Updated author hrefs dorchard-->
<!-- Update Steve's email - bent -->
<author>
<name>Steve DeRose</name>
<affiliation>Inso Corp. and Brown University</affiliation>
<email href="mailto:Steven_DeRose@Brown.edu">Steven_DeRose@Brown.edu</email>
</author>
<author>
<name>David Orchard</name>
<affiliation>IBM Corp.</affiliation>
<email href="mailto:dorchard@ca.ibm.com">dorchard@ca.ibm.com</email>
</author>
<author>
<name>Ben Trafford</name>
<affiliation>Invited Expert</affiliation>
<email href="mailto:bent@exemplary.net">bent@exemplary.net</email>
</author>
<!-- I suggest we move Eve and Tim down to the Acknowledgements section. We
also ought to add Gabe Beged-Dov there, as well. bent
how shall we cite Tim? sjd What about with an Acknowledgments section?
-elm <AUTHOR> <NAME>Tim Bray</NAME> <AFFILIATION>Textuality</AFFILIATION>
<EMAIL>tbray@textuality.com</EMAIL> </AUTHOR>-->
</authlist>
<status>
<p>This is a W3C Working Draft for review by W3C members and other interested parties. It is a draft document and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use W3C Working Drafts as reference material or to cite them as other than "work in progress". A list of current W3C working drafts can be found at <loc href="http://www.w3.org/TR">http://www.w3.org/TR</loc>.</p>
<p><emph>Note:</emph> Since working drafts are subject to frequent change, you are advised to reference the above URI, rather than the URIs for working drafts themselves. Some of the work remaining is described in <specref ref="unfinished"/>. </p>
<p>This work is part of the W3C XML Activity (for current status, see <loc href="http://www.w3.org/MarkUp/SGML/Activity">http://www.w3.org/XML/Activity </loc>). For information about the XPointer language which is expected to be used with XLink, see <loc href="http://www.w3.org/MarkUp/SGML/Activity">http://www.w3.org/TR/WD-xptr</loc>.
</p>
<p>See <loc href="http://www.w3.org/TR/NOTE-xlink-principles">http://www.w3.org/TR/NOTE-xlink-principles </loc> for additional background on the design principles informing XLink.</p>
<p>Also see <loc href="http://www.w3.org/TR/NOTE-xlink-req/">http://www.w3.org/TR/NOTE-xlink-req/</loc> for the XLink requirements that this document attempts to satisfy.</p>
</status>
<abstract>
<!-- edited the abstract for further clarity - bent -->
<p>This specification defines constructs that may be inserted into XML DTDs, schemas and document instances to describe links between objects. It uses XML syntax to create structures that can describe the simple unidirectional hyperlinks of today's HTML as well as more sophisticated links.</p>
</abstract>
<pubstmt>
<p>Burlington, Seekonk, et al.: World-Wide Web Consortium, XML Working Group, 1998.</p>
</pubstmt>
<sourcedesc>
<p>Created in electronic form.</p>
</sourcedesc>
<langusage>
<language id="en">English</language>
<language id="ebnf">Extended Backus-Naur Form (formal grammar)</language>
</langusage>
<revisiondesc>
<slist>
<sitem>1997-01-15 : Skeleton draft by TB</sitem>
<sitem>1997-01-24 : Fleshed out by sjd</sitem>
<sitem>1997-04-08 : Substantive draft</sitem>
<sitem>1997-06-30 : Public draft</sitem>
<sitem>1997-08-01 : Public draft</sitem>
<sitem>1997-08-05 : Prose/organization work by sjd</sitem>
<sitem>1997-10-14: Conformance and design principles; a bit of cleanup by elm</sitem>
<sitem>1997-11-07: Update for editorial issues per issues doc, by sjd.</sitem>
<sitem>1997-12-01: Update for editorial issues per issues doc in preparation for F2F meeting, by sjd.</sitem>
<sitem>1998-01-13: Editorial cleanup, addition of new design principles, by elm.</sitem>
<sitem>1998-02-27: Splitting out of XLink and XPointer, by elm.</sitem>
<sitem>1998-03-03: Moved most of the XPointer locator stuff here. elm</sitem>
<sitem>1999-04-24: Editorial rewrites to represent new ideas on XLink, especially the inclusion of arcs. bent</sitem>
<sitem>1999-05-05: Prose/organization work by dorchard. Moved much of the semantics section around, from: locators, link semantics, remote resource semantics, local resource semantics; to: resource semantics, locators, behavior semantics, link semantics, arc semantics</sitem>
<sitem>1999-05-12: Prose/organization work. Re-organized some of the sections, removed XML constructs from the document, added descriptive prose, edited document text for clarity. Rewrote the link recognition section. bent</sitem>
<sitem>1999-05-17: Further prose work. Added non-normative examples. Clarified arcs. bent</sitem>
<sitem>1999-05-23: Edited for grammar and clarity. bent</sitem>
<sitem>1999-05-27: Final once-over before sending to group. Fixed sjd's email address. bent</sitem>
</slist>
</revisiondesc>
</header>
<body>
<div1><?Pub Dtl?>
<head>Introduction</head>
<p>This specification defines constructs that may be inserted into XML DTDs, schemas, and document instances to describe links between objects. A <termref def="dt-link">link</termref>, as the term is used here, is an explicit relationship between two or more data objects or portions of data objects. This specification is concerned with the syntax used to assert link existence and describe link characteristics. Implicit (unasserted) relationships, for example that of one word to the next or that of a word in a text to its entry in an on-line dictionary are obviously important, but outside its scope.</p>
<p>Links are asserted by <xtermref href="WD-xml-lang.html#dt-element">elements </xtermref> contained in <xtermref href="WD-xml-lang.html#dt-xml-doc">XML document instances</xtermref>. The simplest case is very like an HTML <code>A</code> link, and has these characteristics:
<ulist>
<item><p>The link is expressed at one of its ends (similar to the <code>A</code> element in some document)</p></item>
<item><p>Users can only initiate travel from that end to the other</p></item>
<item><p>The link's effect on windows, frames, go-back lists, stylesheets in use, and so on is mainly determined by browsers, not by the link itself. For example, traveral of <code>A</code> links normally replaces the current view, perhaps with a user option to open a new window.</p></item>
<item><p>The link goes to only one destination (although a server may have great freedom in finding or dynamically creating that destination).</p></item>
</ulist>
</p>
<p>While this set of characteristics is already very powerful and obviously has proven itself highly useful and effective, each of these assumptions also limits the range of hypertext functionality. The linking model defined here provides ways to create links that go beyond each of these specific characteristics, thus providing features previously available mostly in dedicated hypermedia systems.
</p>
<div2>
<head>Origin and Goals</head>
<p>Following is a summary of the design principles governing XLink:
<olist>
<item><p>XLink must be straightforwardly usable over the Internet. </p></item>
<item><p>XLink must be usable by a wide variety of link usage domains and classes of linking application software.</p></item>
<item><p>XLink must support HTML 4.0 linking constructs.</p></item>
<item><p>The XLink expression language must be XML.</p></item>
<item><p>The XLink design must be formal, concise, and illustrative.</p></item>
<item><p>XLinks must be human-readable and human-writable.</p></item>
<item><p>XLinks may reside within or outside the documents in which the
participating resources reside. </p></item>
<item><p>XLink must represent the abstract structure and significance of links.</p></item>
<item><p>XLink must be feasible to implement.</p></item>
<item><p>XLink must be informed by knowledge of established hypermedia systems and standards.</p></item>
</olist>
</p>
</div2>
<!--Changed the list of requirements to reflect current XLink requirements
document. bent-->
<div2>
<head>Relationship to Existing Standards</head>
<p>Three standards have been especially influential:
<ulist>
<item><p><emph>HTML:</emph> Defines several SGML element types that represent links.</p></item>
<item><p><emph>HyTime:</emph> Defines inline and out-of-line link structures and some semantic features, including traversal control and presentation of objects. <!--Changed from "placement of objects into a display or other space" -elm-->
</p></item>
<item><p><emph>Text Encoding Initiative Guidelines (TEI P3):</emph> Provides structures for creating links, aggregate objects, and link collections out of them.</p></item>
</ulist>
</p>
<p>Many other linking systems have also informed this design, especially Dexter, FRESS, MicroCosm, and InterMedia.</p>
</div2>
<div2>
<head>Terminology</head>
<p>The following basic terms apply in this document. <!--<IMG
SRC="local://./linkdiag.gif">(figure to be inserted)-->
<glist>
<gitem>
<label><termdef id="dt-arc" term="Arc">arc</termdef></label>
<def><p>A symbolic representation of traversal behavior in links, especially the direction, context and timing of traversal.</p></def>
</gitem>
<gitem>
<label><termdef id="dt-eltree" term="Element Tree">element tree</termdef></label>
<def><p>A representation of the relevant structure specified by the tags and attributes in an XML document, based on "groves" as defined in the ISO DSSSL standard. </p></def>
</gitem>
<gitem>
<label><termdef id="dt-inline" term="In-Line Link">inline link</termdef></label>
<def><p>Abstractly, a <termref def="dt-link">link</termref> which serves as one of its own <termref def="dt-resource">resources</termref>. Concretely, a link where the content of the <termref def="dt-linkel">linking element</termref> serves as a <termref def="dt-particip-resource">participating resource</termref>.
HTML <code>A</code>, HyTime <code>clink</code>, and TEI <code>XREF</code>
are all inline links.</p></def>
</gitem>
<gitem>
<label><termdef id="dt-link" term="Link">link</termdef></label>
<def><p>An explicit relationship between two or more data objects or portions of data objects.</p></def>
</gitem>
<gitem>
<label><termdef id="dt-linkel" term="Linking Element">linking element </termdef></label>
<def><p>An <xtermref href="WD-xml-lang.html#dt-element">element</xtermref> that asserts the existence and describes the characteristics of a <termref def="dt-link"> link</termref>.</p></def>
</gitem>
<gitem>
<label><termdef id="dt-local-resource" term="Local Resource">local resource</termdef></label>
<def><p>The content of an <termref def="dt-inline">inline</termref>linking element. Note that the content of the linking element could be explicitly pointed to by means of a regular <termref def="dt-locator">locator</termref> in the same linking element, in which case the resource is considered <termref def="dt-remote-resource"> remote</termref>, not local.</p></def>
</gitem>
<gitem>
<label><termdef id="dt-locator" term="Locator">locator</termdef> </label>
<def><p>Data, provided as part of a link, which identifies a
<termref def="dt-resource">resource</termref>.</p></def>
</gitem>
<gitem>
<label><termdef id="dt-multidir" term="Multi-Directional Link">multidirectional link</termdef></label>
<def><p>A <termref def="dt-link">link</termref> whose <termref def="dt-traversal"> traversal</termref> can be initiated from more than one of its <termref def="dt-particip-resource"> participating resources</termref>. Note that being able to "go back" after following a one-directional link does not make the link multidirectional.</p></def>
</gitem>
<gitem>
<label><termdef id="dt-outofline" term="Out-of-line Link">out-of-line link</termdef></label>
<def><p>A <termref def="dt-link">link</termref> whose content does not serve as one of the link's <termref def="dt-particip-resource">participating resources </termref>. Such links presuppose a notion like <termref def="dt-xlg">extended link groups</termref>, which instruct application software where to look for links. Out-of-line links are generally required for supporting multidirectional <termref def="dt-traversal">traversal</termref> and for allowing read-only resources to have outgoing links.</p></def>
</gitem>
<gitem>
<label><termdef id="dt-parsedq" term="Parsed">parsed</termdef></label> <def><p>In the context of link behavior, a parsed link is any link whose content is transcluded into the document where the link originated. The use of the term "parsed" directly refers to the concept in XML of a
parsed entity.</p></def>
</gitem>
<gitem>
<label><termdef id="dt-particip-resource" term="Participating Resource"> participating resource</termdef></label>
<def><p>A <termref def="dt-resource">resource</termref> that belongs to a link. All resources are potential contributors to a link; participating resources are the actual contributors to a particular link.</p></def>
</gitem>
<gitem>
<label><termdef id="dt-remote-resource" term="Remote Resource">remote resource</termdef></label>
<def><p>Any participating resource of a link that is pointed to with a locator. </p></def>
</gitem>
<gitem>
<label><termdef id="dt-resource" term="Resource">resource</termdef></label>
<def><p>In the abstract sense, an addressable unit of information or service that is participating in a <termref def="dt-link">link</termref>. Examples include files, images, documents, programs, and query results. Concretely, anything reachable by the use of a <termref def="dt-locator">locator</termref> in some <termref def="dt-linkel">linking element</termref>. Note that this term and its definition are taken from the basic specifications governing the World Wide Web. <!--Joel notes: need link here. bent asks: A link?-->
</p></def>
</gitem>
<gitem>
<label><termdef id="dt-subresource" term="sub-Resource">sub-resource</termdef></label>
<def><p>A portion of a resource, pointed to as the precise destination of a link. As one example, a link might specify that an entire document be retrieved and displayed, but that some specific part(s) of it is the specific linked data, to be treated in an application-appropriate manner such as indication by highlighting, scrolling, etc.</p></def>
</gitem>
<gitem>
<label><termdef id="dt-traversal" term="Traversal">traversal</termdef></label>
<def><p>The action of using a <termref def="dt-link">link</termref>; that is, of accessing a <termref def="dt-resource">resource</termref>. Traversal may be initiated by a user action (for example, clicking on the displayed content of a <termref def="dt-linkel">linking element</termref>) or occur under program control.</p></def>
</gitem>
</glist>
</p>
</div2>
<div2>
<head>Notation</head>
<p>The formal grammar for <termref def="dt-locator">locators</termref> is given using a simple Extended Backus-Naur Form (EBNF) location, as described in <xspecref href="http://www.w3.org/TR/REC-xml#sec-notation">the XML specification</xspecref>.</p>
<!-- fixed link to XML spec - bent -->
</div2>
</div1>
<div1 id="addressing"><?Pub Dtl?>
<head>Locator Syntax</head>
<p>The locator for a <termref def="dt-resource">resource</termref> is typically provided by means of a Uniform Resource Identifier, or URI. XPointers can be used in conjunction with the URI structure, as fragment identifiers, to specify a more precise sub-resource. </p>
<!-- Removed the discussion of queries from the previous paragraph, due to contention within the WG. bent -->
<p>A locator generally contains a URI, as described in IETF RFCs <bibref ref="rfc1738"/> and <bibref ref="rfc1808"/>. As these RFCs state, the URI may include a trailing <emph>query</emph> (marked by a leading "<code>?</code>"), and be followed by a "<code>#</code>" and a <emph>fragment identifier</emph>, with the query interpreted by the host providing the indicated resource, and the interpretation of the fragment identifier dependent on the data type of the indicated resource.</p>
<!--Is there some restriction on URNs having queries and/or fragment identifiers? Since these RFCs don't mention URIs explicitly, should the wording here lead from URLs to URIs more explicitly? -elm-->
<p>In order to locate XML documents and portions of documents, a locator value may contain either a <xtermref href="http://www.w3.org/Addressing/rfc1738.txt"> URI</xtermref> or a fragment identifier, or both. Any fragment identifier for pointing into XML must be an <xtermref href="http://www.w3.org/TR/WD-xptr#dt-xpointer"> XPointer</xtermref>.</p>
<p>Special syntax may be used to request the use of particular processing models in accessing the locator's resource. This is designed to reflect the realities of network operation, where it may or may not be desirable to exercise fine control over the distribution of work between local and remote processors.
<scrap id="locator" lang="ebnf">
<head>Locator</head>
<prod id="nt-locator">
<lhs>Locator</lhs>
<rhs><nt def="nt-uri">URI</nt></rhs>
<rhs>| <nt def="nt-connector">Connector</nt> (<xnt href="http://www.w3.org/TR/WD-xptr">XPointer</xnt> | <xnt href="WD-xml-lang.html#NT-Name">Name</xnt>)</rhs>
<rhs>| <nt def="nt-uri">URI</nt> <nt def="nt-connector">Connector</nt> (<xnt href="http://www.w3.org/TR/WD-xptr">XPointer</xnt> | <xnt href="WD-xml-lang.html#NT-Name">Name</xnt>)</rhs>
</prod>
<prod id="nt-connector">
<lhs>Connector</lhs><rhs>'#' | '|'</rhs>
</prod>
<prod id="nt-uri">
<lhs>URI</lhs><rhs><xnt href="WD-xml-lang.html#NT-URLchar">URIchar*</xnt></rhs>
</prod>
</scrap>
</p>
<p><termdef id="dt-designated" term="Designated Resource">In this discussion, the term <term>designated resource</term> refers to the resource which an entire locator serves to locate.</termdef> The following rules apply:
<ulist>
<item>
<p><termdef id="dt-containing-resource" term="Containing Resource"> The URI, if provided, locates a resource called the <term>containing resource</term>.</termdef></p>
</item>
<item>
<p>If the URI is not provided, the containing resource is considered to be the document in which the linking element is contained.
</p></item>
<item>
<p><termdef id="dt-sub-resource" term="Sub-Resource">If an XPointer is provided, the designated resource is a <term>sub-resource</term>
of the containing resource; otherwise the designated resource is the
containing resource.</termdef></p>
</item>
<!--Is this now incorrect, given the nature of the switch from here() to origin()? -elm
Oy, yes, i think so. it will require some fun wording, though, so i haven't fixed it yet here -sjd-->
<item>
<p>If the <nt def="nt-connector">Connector</nt> is followed directly by a <xnt href="http://www.w3.org/TR/REC-xml#NT-Name">Name</xnt>, the <xnt href="http://www.w3.org/TR/REC-xml#NT-Name">Name</xnt> is shorthand for the XPointer"<code>id(Name)</code>"; that is, the sub-resource is the element in the containing resource that has an XML <xtermref href="http://www.w3.org/TR/REC-xml#sec-attrtypes">ID attribute</xtermref> whose value <xtermref href="http://www.w3.org/TR/REC-xml#dt-match">matches</xtermref> the <xnt href="http://www.w3.org/TR/REC-xml#NT-Name">Name</xnt>. This shorthand is to encourage use of the robust <code>id</code> addressing mode.</p>
</item>
<!-- fixed links to the XML recommendation - bent -->
<item>
<p>If the connector is "<code>#</code>", this signals an intent that the containing resource is to be fetched as a whole from the host that provides it, and that the XPointer processing to extract the sub-resource
is to be performed on the client, that is to say on the same system where the linking element is recognized and processed.</p>
</item>
<item>
<p>If the connector is "<code>|</code>", no intent is signaled as to what processing model is to be used to go about accessing the designated resource.</p>
</item>
</ulist>
</p>
<p>Note that the definition of a URI includes an optional query component. </p>
<p>In the case where the URI contains a query (to be interpreted by the server), information providers and authors of server software are urged to use queries as follows:
<scrap id="querysyntax" lang="ebnf">
<head>Query</head>
<prod id="nt-query">
<lhs>Query</lhs><rhs>'XML-XPTR=' (<xnt href="http://www.w3.org/TR/WD-xptr"> XPointer</xnt> | <xnt href="http://www.w3.org/TR/REC-xml#NT-Name">Name</xnt>)</rhs>
</prod>
</scrap>
</p>
<!-- fixed link to XML recommendation - bent -->
</div1>
<div1><?Pub Dtl?>
<head>Link Recognition</head>
<p>The existence of a <termref def="dt-link">link</termref> is asserted by a <termref def="dt-linkel">linking element</termref>. Linking elements must be recognized reliably by application software in order to provide appropriate display and behavior. There are several ways link recognition could be accomplished: for example, reserving element type names, reserving attributes names, leaving the matter of recognition entirely up to stylesheets and application software, or using the XLink <xtermref href="http://www.w3.org/TR/REC-xml-names/">namespace</xtermref> to specify element names and attribute names that would be recognized by namespace and XLink-aware processors. Using element and attribute names within the XLink namespace provides a balance between giving users control of their own markup language design and keeping the identification of linking elements simple and unambiguous.</p>
<p>The two approaches to identifying linking elements are relatively simple to implement. For example, here's how the HTML <code>A</code> element would be declared using attributes within the XLink namespace, and then how an element within the XLink namespace might do the same:
<eg>&lt;A xlink:type="simple" xlink:href="http://www.w3.org/TR/wd-xlink/"
xlink:title="The Xlink Working Draft"&gt;The XLink Working Draft.&lt;/A&gt;</eg>
<eg>&lt;xlink:simple href="http://www.w3.org/TR/wd-xlink/"
title="The XLink Working Draft"&gt;The XLink Working Draft&lt;/xlink:simple&gt;</eg>
Any arbitrary element can be made into an XLink by using the <code>xlink:type</code> attribute. And, of course, the explicit XLink elements may be used, as well. This document will go on to describe the linking attributes that are associated with linking elements. It may be assumed by the reader that these attributes would require the <code>xlink</code> namespace prefix if they existed within an arbitrary element, or that they may be used directly if they exist within an explicit Xlink element.</p>
<!-- heavily modified this section to accomodate namespace-aware link recognition - bent -->
</div1>
<!-- Rewrote this entire section. - bent -->
<div1>
<head>Linking Attributes</head>
<p>XLink has several attributes associated with the variety of links it may represent. These attributes define four main concepts: locators, arcs, behaviors, and semantics. <emph>Locators</emph> define where the actual resource is located. <emph>Arcs</emph> define the traversal of links. Where does the link come from? Where does it go to? All this information can be stored in the arc attributes. <emph>Behaviors</emph> define how the link is activated, and what the application should do with the resource being linked to. <emph>Semantics</emph> define useful information that the application may use, and enables the link for such specalized targets as constricted devices and accessibility software.</p>
<div2 id="link-locators">
<head>Locator Attributes</head>
<p>The only locator attribute at this time is <code>href</code>. This attribute must contain either a string in the form of a URI that defines the remote resource being linked to, a string containing a fragment identifier that links to a local resource, or a string containing a URI with a fragment identifier concacenated onto it.</p>
</div2>
<div2 id="link-arcs">
<head>Arc Attributes</head>
<p>Arcs contain two attributes, <code>from</code> and <code>to</code>. The <code>from</code> attribute may contain a string containing the content of a <code>role</code> attribute from the resource being linked from. The purpose of the <code>from</code> attribute is to define where this link is being actuated from.</p>
<p>The <code>to</code> attribute may contain a string containing the content of a <code>role</code> attribute from the resource being linked to. The purpose of the <code>to</code> attribute is to define where this link traverses to.</p>
<p>The application may use this information in a number of ways, especially in a complex hypertext system, but it is mainly useful in providing context for application behavior.</p>
<!-- I'm at a loss as to how to describe arcs more clearly than this. I don't want to devolve into discussions of directed graphs and n-ary links. -bent -->
</div2>
<div2 id="link-behaviors">
<head>Behavior Attributes</head>
<p>There are two attributes associated with behavior: <code>show</code> and <code>actuate</code>. The <code>show</code> attribute defines how the remote resource is to be revealed to the user. It has three options: <code>new</code>, <code>parsed</code>, and <code>replace</code>. The <code>new</code> option indicates that the remote resource should be shown in a new window (or other device context) without replacing the previous content. The <code>parsed</code> option, relating directly to the XML concept of a parsed entity, indicates that the content should be integrated into the document from which the link was actuated. The <code>replace</code> option is the one most commonly seen on the World Wide Web, where the document being linked from is entirely replaced by the object being linked to.</p>
<p>The <code>actuate</code> attribute defines how the link is initiated. It has two options: <code>user</code> and <code>auto</code>. The <code>user</code> option indicates that the link must be initiated by some sort of human-initiated selection, such as clicking on an HTML anchor. The <code>auto</code> option indicates that the link is automatically initiated when the application deems that the user has reached the link. It then follows the behavior set out in the <code>show</code> option.</p>
<!-- Something should be put here in terms of an example. Idea: "A" link versus automatically updating encyclopedia. -bent -->
</div2>
<div2 id="link-semantics">
<head>Semantic Attributes</head>
<p>There are two attributes associated with semantics, <code>role</code> and <code>title</code>. The <code>role</code> attribute is a generic string used to describe the function of the link's content. For example, a poem might have a link with a <code>role="stanza"</code>. The <code>role</code> is also used as an identifier for the <code>from</code> and <code>to</code> attributes of arcs.</p>
<p>The <code>title</code> attribute is designed to provide human-readable text describing the link. It is very useful for those who have text-based applications, whether that be due to a constricted device that cannot display the link's content, or if it's being read by an application to a visually-impaired user, or if it's being used to create a table of links. The <code>title</code> attribute contains a simple, descriptive string.</p>
</div2>
</div1>
<div1 id="linking-elements">
<head>Linking Elements</head>
<p>There are several kinds of linking elements in XLink: <code>simple</code> links, <code>locators</code>, <code>arcs</code>, and <code>extended</code> links. These elements may be instantiated via element declarations from the XLink namespace, or they may be instantiated via attribute declarations from the XLink namespace. Both kinds of instantiation are described in the definition of each linking element.</p>
<p>The <code>simple</code> link is used to declare a link that approximates the functionality of the HTML <code>A</code> element. It has, however, a few added features to increase its value, including the potential declaration of semantics and behavior. The <code>locator</code> elements are used to define the resource being linked to. Some links may contain multiple locators, representing a choice of potential links to be traversed. The <code>arcs</code> are used to define the traversal semantics of the link. Finally, an <code>extended</code> linking element differs from a simple link in that it can connect any number of resources, not just one local resource (optionally) and one remote resource, and in that extended links are more often out-of-line than simple links.</p>
<div2 id="simple-links">
<head>Simple Links</head>
<p id="dt-simplelink"><termdef id="dt-simpleline" term="Simple Link"><term>Simple links</term> can be used for purposes that approximate the functionality of a basic HTML <code>A</code> link, but they can also support a limited amount of additional functionality. Simple links have only one locator and thus, for convenience, combine the functions of a linking element and a locator into a single element.</termdef> As a result of this combination, the simple linking element offers both a locator attribute and all the behavior and semantic attributes.</p>
<p>The following are two examples of linking elements, each showing all the possible attributes that can be associated with a simple link. Here is the explicit XLink simple linking element.
<eg>&lt;!ELEMENT xlink:simple ANY&gt;
&lt;!ATTLIST xlink:slink
href CDATA #REQUIRED
role CDATA #IMPLIED
title CDATA #IMPLIED
show (new|parsed|replace) "replace"
actuate (user|auto) "user"
&gt;</eg>
And here is how to make an arbitrary element into a simple link.
<eg>&lt;!ELEMENT xlink:simple ANY&gt;
&lt;!ATTLIST foo
xlink:type (simple|extended|locator|arc) #FIXED "simple"
xlink:href CDATA #REQUIRED
xlink:role CDATA #IMPLIED
xlink:title CDATA #IMPLIED
xlink:show (new|parsed|replace) "replace"
xlink:actuate (user|auto) "user"
&gt;</eg>
Here is how the first example might look in a document:
<eg>&lt;xlink:simple href="http://www.w3.org/TR/wd-xlink" role="working draft"
title="The XLink Working Draft" show="replace" actuate="user"&gt;
The XLink Working Draft.&lt;/xlink:simple&gt;</eg>
<eg>&lt;foo xlink:href="http://www.w3.org/TR/wd-xlink" xlink:role="working draft"
xlink:title="The XLink Working Draft" xlink:show="new" xlink:actuate="user"&gt;
The XLink Working Draft.&lt;/foo&gt;</eg>
Alternately, a simple link could be as terse as this:
<eg>&lt;foo xlink:href="#stanza1"&gt;The First Stanza.&lt;/foo&gt;</eg>
</p>
<p>
There are no constraints on the contents of a simple linking element. In
the sample declaration above, it is given a content model of <code>ANY</code>
to illustrate that any content model or declared content is acceptable. In
a valid document, every element that is significant to XLink must still conform
to the constraints expressed in its governing DTD.</p>
<p>Note that it is meaningful to have an out-of-line simple link, although
such links are uncommon. They are called "one-ended" and are typically used
to associate discrete semantic properties with locations. The properties might
be expressed by attributes on the link, the link's element type name, or in
some other way, and are not considered full-fledged resources of the link.
Most out-of-line links are extended links, as these have a far wider range
of uses.</p>
</div2>
<div2 id="extended-link">
<head>Extended Links</head>
<p><termdef id="dt-extendedlink" term="Extended Link">An <term>extended link</term> differs from a simple link in that it can connect any number of resources, not just one local resource (optionally) and one remote resource, and in that extended links are more often out-of-line than simple links.</termdef></p>
<p>These additional capabilities of extended links are required for:
<ulist>
<item>
<p>Enabling outgoing links in documents that cannot be modified to add an inline link</p>
</item>
<item>
<p>Creating links to and from resources in formats with no native support for embedded links (such as most multimedia formats)</p>
</item>
<item>
<p>Applying and filtering sets of relevant links on demand</p>
</item>
<item><p>Enabling other advanced hypermedia capabilities</p></item>
</ulist>
</p>
<p>Application software might be expected to provide traversal among all of a link's participating resources (subject to semantic constraints outside the scope of this specification) and to signal the fact that a given resource or sub-resource participates in one or more links when it is displayed (even though there is no markup at exactly that point to signal it).</p>
<p>A linking element for an extended link contains a series of <xtermref href="http://www.w3.org/TR/REC-xml/#dt-parentchild">child elements</xtermref> that serve as locators and arcs. Because an extended link can have more than one remote resource, it separates out linking itself from the mechanisms used to locate each resource (whereas a simple link combines the two).</p>
<p>The <code>xlink:type</code> attribute value for an extended link must be <code> extended</code>, if the link is being instantiated on an arbitrary element. Note that extended links introduce variants of the <code>show</code> and <code>actuate</code> behavior attributes. These attributes, the <code>showdefault</code> and <code>actuatedefault</code> define the same behavior as their counterparts. However, in this case, they are considered to define the default behavior for all the linking elements that they contain.</p>
<p>However, when a linking element within an extended link has a <code>show</code> or <code>actuate</code> attribute of its own, that attribute overrides the defaults set on the extended linking element.</p>
<p>The extended linking element itself retains those attributes relevant to the link as a whole, and to its local resource if any. Following are two sample declaration for an extended link. The first is an example of the explicit XLink extended link:
<eg>&lt;!ELEMENT xlink:extended ((xlink:arc | xlink:locator)*)>
&lt;!ATTLIST xlink:extended
role CDATA #IMPLIED
title CDATA #IMPLIED
showdefault (new|parsed|replace) #IMPLIED
actuatedefault (user|auto) #IMPLIED &gt;</eg>
The second is an example of an arbitrary element being used an extended link:
<eg>&lt;!ELEMENT foo ((xlink:arc | xlink:locator)*)>
&lt;!ATTLIST foo
xlink:type (simple|extended|locator|arc) #FIXED "extended"
xlink:role CDATA #IMPLIED
xlink:title CDATA #IMPLIED
xlink:showdefault (new|parsed|replace) #IMPLIED
xlink:actuatedefault (user|auto) #IMPLIED &gt;</eg>
The following two examples demonstrate how each of the above might appear within a document instance. Note that the content of these examples would be other elements. For brevity's sake, they've been left blank. The first example shows how the link might appear, using an explicit XLink extended link:
<eg>&lt;xlink:extended role="address book" title="Ben's Address Book" showdefault="replace" actuatedefault="user"&gt; ... &lt;/xlink:extended&gt;</eg>
And the second shows how the link might appear, using an arbitrary element:
<eg>&lt;foo xlink:type="extended" xlink:role="address book" xlink:title="Ben's Address Book" xlink:showdefault="replace" xlink:actuatedefault="user"&gt; ... &lt;/foo&gt;</eg>
</p>
</div2>
<div2 id="xlink-arcs">
<head>Arc Elements</head>
<p><termdef id="dt-arc" term="Arc">An <term>arc</term> is contained within an extended link for the purpose of defining traversal behavior.</termdef> More than one arc may be associated with a link. Otherwise, arc elements function exactly as the arc attributes might lead on to expect.</p>
<!-- More here? -bent -->
</div2>
</div1>
<div1>
<head>Conformance</head>
<p>An element conforms to XLink if: <olist>
<item><p>The element has an <code>xml:link</code> attribute whose value is
one of the attribute values prescribed by this specification, and</p></item>
<item><p>the element and all of its attributes and content adhere to the
syntactic
requirements imposed by the chosen <code>xml:link</code> attribute value,
as prescribed in this specification.</p></item>
</olist></p>
<p>Note that conformance is assessed at the level of individual elements,
rather than whole XML documents, because XLink and non-XLink linking mechanisms
may be used side by side in any one document.</p>
<p>An application conforms to XLink if it interprets XLink-conforming elements
according to all required semantics prescribed by this specification and,
for any optional semantics it chooses to support, supports them in the way
prescribed. <!--If/when we split out the XLinkfunctionality
(e.g. inline links and out-of-line links), the
conformance language will have to address the different
levels of support. -elm--> </p>
</div1>
</body><back>
<div1 id="unfinished">
<head>Unfinished Work</head>
<div2>
<head>Structured Titles</head>
<p>The simple title mechanism described in this draft is insufficient to cope
with internationalization or the use of multimedia in link titles. A future
version will provide a mechanism for the use of structured link titles.</p>
</div2>
</div1>
<div1>
<head>References</head>
<blist>
<bibl id="xptr" key="XPTR">Eve Maler and Steve DeRose, editors. <titleref>
XML Pointer Language (XPointer) V1.0</titleref>. ArborText, Inso, and Brown
University. Burlington, Seekonk, et al.: World Wide Web Consortium, 1998.
(See <loc href="http://www.w3.org/TR/WD-xptr">http://www.w3.org/TR/WD-xptr
</loc>.)</bibl>
<bibl id="iso10744" key="ISO/IEC 10744">ISO (International Organization for
Standardization). <titleref>ISO/IEC 10744-1992 (E). Information technology
- Hypermedia/Time-based Structuring Language (HyTime).</titleref> [Geneva]:
International Organization for Standardization, 1992. <titleref>Extended
Facilities
Annex.</titleref> [Geneva]: International Organization for Standardization,
1996. (See <loc
href="http://www.ornl.gov/sgml/wg8/hytime/html/is10744r.html">http://www.ornl.go
v/sgml/wg8/hytime/html/is10744r.html </loc> <!--p m-r says this link is
broken. elm --> ).</bibl>
<bibl id="rfc1738" key="IETF RFC 1738">IETF (Internet Engineering Task
Force). <titleref>
RFC 1738: Uniform Resource Locators</titleref>. 1991. (See <loc
href="http://www.w3.org/Addressing/rfc1738.txt">
http://www.w3.org/Addressing/rfc1738.txt</loc>).</bibl>
<bibl id="rfc1808" key="IETF RFC 1808">IETF (Internet Engineering Task
Force). <titleref>
RFC 1808: Relative Uniform Resource Locators</titleref>. 1995. (See <loc
href="http://www.w3.org/Addressing/rfc1808.txt">http://www.w3.org/Addressing/rfc
1808.txt </loc>).</bibl>
<bibl id="tei" key="TEI">C. M. Sperberg-McQueen and Lou Burnard, editors.
<titleref>
Guidelines for Electronic Text Encoding and Interchange</titleref>. Association
for Computers and the Humanities (ACH), Association for Computational
Linguistics
(ACL), and Association for Literary and Linguistic Computing (ALLC). Chicago,
Oxford: Text Encoding Initiative, 1994. <!-- add cite to DOM work --> </bibl>
<bibl id="chum" key="CHUM">]Steven J. DeRose and David G. Durand. 1995. "The
TEI Hypertext Guidelines." In <titleref>Computing and the Humanities
</titleref>29(3).
Reprinted in <titleref>Text Encoding Initiative: Background and
Context</titleref>,
ed. Nancy Ide and Jean ronis <!-- fix this name -->, ISBN 0-7923-3704-2. </bibl>
</blist></div1>
</back></spec>
<?Pub *0000052575?>

3
test/warning/ent8 Normal file
View File

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<!DOCTYPE a SYSTEM "a.dtd">
<a> &unknown; but Okay </a>

View File

@ -61,6 +61,7 @@ xmlSAXHandler emptySAXHandlerStruct = {
NULL, /* xmlParserWarning */
NULL, /* xmlParserError */
NULL, /* xmlParserError */
NULL, /* getParameterEntity */
};
xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct;
@ -156,7 +157,10 @@ internalSubsetDebug(xmlParserCtxtPtr ctxt, const CHAR *name,
name, ExternalID, SystemID);
if ((ExternalID != NULL) || (SystemID != NULL)) {
externalSubset = xmlSAXParseDTD(debugSAXHandler, ExternalID, SystemID);
externalSubset = xmlParseDTD(ExternalID, SystemID);
if (externalSubset != NULL) {
xmlFreeDtd(externalSubset);
}
}
}
@ -209,6 +213,22 @@ getEntityDebug(xmlParserCtxtPtr ctxt, const CHAR *name)
return(NULL);
}
/**
* getParameterEntityDebug:
* @ctxt: An XML parser context
* @name: The entity name
*
* Get a parameter entity by name
*
* Returns the xmlParserInputPtr
*/
xmlEntityPtr
getParameterEntityDebug(xmlParserCtxtPtr ctxt, const CHAR *name)
{
fprintf(stdout, "SAX.getParameterEntity(%s)\n", name);
return(NULL);
}
/**
* entityDeclDebug:
@ -541,6 +561,7 @@ xmlSAXHandler debugSAXHandlerStruct = {
warningDebug,
errorDebug,
fatalErrorDebug,
getParameterEntityDebug,
};
xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct;

View File

@ -81,7 +81,12 @@ void xmlXPAthDebugDumpNodeSet(FILE *output, xmlNodeSetPtr cur) {
fprintf(output, "Set contains %d nodes:\n", cur->nodeNr);
for (i = 0;i < cur->nodeNr;i++) {
fprintf(output, "%d", i + 1);
xmlDebugDumpOneNode(output, cur->nodeTab[i], 2);
if (cur->nodeTab[i] == NULL)
fprintf(output, " NULL\n");
else if (cur->nodeTab[i]->type == XML_DOCUMENT_NODE)
fprintf(output, " /\n");
else
xmlDebugDumpOneNode(output, cur->nodeTab[i], 2);
}
}

View File

@ -35,6 +35,10 @@ static int copy = 0;
static int recovery = 0;
static int noent = 0;
static int noout = 0;
static int valid = 0;
static int repeat = 0;
extern int xmlDoValidityCheckingDefaultValue;
/*
* Note: there is a couple of errors introduced on purpose.
@ -178,7 +182,7 @@ void parseAndPrintBuffer(CHAR *buf) {
}
int main(int argc, char **argv) {
int i;
int i, count;
int files = 0;
for (i = 1; i < argc ; i++) {
@ -195,11 +199,22 @@ int main(int argc, char **argv) {
else if ((!strcmp(argv[i], "-noout")) ||
(!strcmp(argv[i], "--noout")))
noout++;
else if ((!strcmp(argv[i], "-valid")) ||
(!strcmp(argv[i], "--valid")))
valid++;
else if ((!strcmp(argv[i], "-repeat")) ||
(!strcmp(argv[i], "--repeat")))
repeat++;
}
if (noent != 0) xmlSubstituteEntitiesDefault(1);
if (valid != 0) xmlDoValidityCheckingDefaultValue = 1;
for (i = 1; i < argc ; i++) {
if (argv[i][0] != '-') {
parseAndPrintFile(argv[i]);
if (repeat) {
for (count = 0;count < 100 * repeat;count++)
parseAndPrintFile(argv[i]);
} else
parseAndPrintFile(argv[i]);
files ++;
}
}
@ -212,6 +227,7 @@ int main(int argc, char **argv) {
printf("\t--recover : output what is parsable on broken XmL documents\n");
printf("\t--noent : substitute entity references by their value\n");
printf("\t--noout : don't output the result\n");
printf("\t--repeat : parse the file 100 times, for timing or profiling\n");
}
return(0);

54
tree.c
View File

@ -1126,6 +1126,46 @@ xmlNewComment(const CHAR *content) {
return(cur);
}
/**
* xmlNewCDataBlock:
* @doc: the document
* @content: the CData block content content
* @len: the length of the block
*
* Creation of a new node containing a CData block.
* Returns a pointer to the new node object.
*/
xmlNodePtr
xmlNewCDataBlock(xmlDocPtr doc, const CHAR *content, int len) {
xmlNodePtr cur;
/*
* Allocate a new node and fill the fields.
*/
cur = (xmlNodePtr) malloc(sizeof(xmlNode));
if (cur == NULL) {
fprintf(stderr, "xmlNewCDataBlock : malloc failed\n");
return(NULL);
}
cur->type = XML_CDATA_SECTION_NODE;
cur->doc = NULL;
cur->parent = NULL;
cur->prev = NULL;
cur->next = NULL;
cur->childs = NULL;
cur->last = NULL;
cur->properties = NULL;
cur->name = xmlStrdup(xmlStringText);
cur->ns = NULL;
cur->nsDef = NULL;
if ((content != NULL) && (len > 0)) {
cur->content = xmlStrndup(content, len);
} else
cur->content = NULL;
return(cur);
}
/**
* xmlNewDocComment:
* @doc: the document
@ -1725,7 +1765,6 @@ xmlNodeGetContent(xmlNodePtr cur) {
return(xmlNodeListGetString(cur->doc, cur->childs, 1));
break;
case XML_ATTRIBUTE_NODE:
case XML_CDATA_SECTION_NODE:
case XML_ENTITY_REF_NODE:
case XML_ENTITY_NODE:
case XML_PI_NODE:
@ -1734,6 +1773,7 @@ xmlNodeGetContent(xmlNodePtr cur) {
case XML_DOCUMENT_TYPE_NODE:
case XML_NOTATION_NODE:
return(NULL);
case XML_CDATA_SECTION_NODE:
case XML_TEXT_NODE:
if (cur->content != NULL)
return(xmlStrdup(cur->content));
@ -2637,6 +2677,13 @@ xmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level) {
xmlBufferWriteChar(buf, ";");
return;
}
if (cur->type == XML_CDATA_SECTION_NODE) {
xmlBufferWriteChar(buf, "<![CDATA[");
if (cur->content != NULL)
xmlBufferWriteCHAR(buf, cur->content);
xmlBufferWriteChar(buf, "]]>");
return;
}
if (xmlIndentTreeOutput)
for (i = 0;i < level;i++)
xmlBufferWriteChar(buf, " ");
@ -2747,10 +2794,9 @@ xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size) {
return;
}
xmlDocContentDump(buf, cur);
*mem = buf->content;
*mem = xmlStrndup(buf->content, buf->use);
*size = buf->use;
memset(buf, -1, sizeof(xmlBuffer));
free(buf);
xmlBufferFree(buf);
}
/**

9
tree.h
View File

@ -97,6 +97,7 @@ typedef xmlEnumeration *xmlEnumerationPtr;
typedef struct xmlAttribute {
const CHAR *elem; /* Element holding the attribute */
const CHAR *name; /* Attribute name */
struct xmlAttribute *next; /* list of attributes of an element */
xmlAttributeType type; /* The type */
xmlAttributeDefault def; /* the default */
const CHAR *defaultValue;/* or the default value */
@ -138,9 +139,10 @@ typedef enum {
} xmlElementTypeVal;
typedef struct xmlElement {
const CHAR *name; /* Element name */
xmlElementTypeVal type; /* The type */
const CHAR *name; /* Element name */
xmlElementTypeVal type; /* The type */
xmlElementContentPtr content; /* the allowed element content */
xmlAttributePtr attributes; /* List of the declared attributes */
} xmlElement;
typedef xmlElement *xmlElementPtr;
@ -188,7 +190,7 @@ typedef struct xmlAttr {
#endif
xmlElementType type; /* XML_ATTRIBUTE_NODE, must be third ! */
struct xmlNode *node; /* attr->node link */
struct xmlAttr *next; /* parent->childs link */
struct xmlAttr *next; /* attribute list link */
const CHAR *name; /* the name of the property */
struct xmlNode *val; /* the value of the property */
} xmlAttr;
@ -310,6 +312,7 @@ xmlNodePtr xmlNewDocTextLen(xmlDocPtr doc, const CHAR *content, int len);
xmlNodePtr xmlNewTextLen(const CHAR *content, int len);
xmlNodePtr xmlNewDocComment(xmlDocPtr doc, const CHAR *content);
xmlNodePtr xmlNewComment(const CHAR *content);
xmlNodePtr xmlNewCDataBlock(xmlDocPtr doc, const CHAR *content, int len);
xmlNodePtr xmlNewReference(xmlDocPtr doc, const CHAR *name);
xmlNodePtr xmlCopyNode(xmlNodePtr node, int recursive);
xmlNodePtr xmlCopyNodeList(xmlNodePtr node);

1402
valid.c

File diff suppressed because it is too large Load Diff

55
valid.h
View File

@ -11,6 +11,22 @@
#define __XML_VALID_H__
#include "tree.h"
/**
* an xmlValidCtxt is used for error reporting when validating
*/
typedef void (*xmlValidityErrorFunc) (void *ctx, const char *msg, ...);
typedef void (*xmlValidityWarningFunc) (void *ctx, const char *msg, ...);
typedef struct xmlValidCtxt {
void *userData; /* user specific data block */
xmlValidityErrorFunc error; /* the callback in case of errors */
xmlValidityWarningFunc warning; /* the callback in case of warning */
} xmlValidCtxt, *xmlValidCtxtPtr;
extern void xmlParserValidityError(void *ctx, const char *msg, ...);
extern void xmlParserValidityWarning(void *ctx, const char *msg, ...);
/*
* ALl notation declarations are stored in a table
* there is one table per DTD
@ -21,7 +37,7 @@
typedef struct xmlNotationTable {
int nb_notations; /* number of notations stored */
int max_notations; /* maximum number of notations */
xmlNotationPtr table; /* the table of attributes */
xmlNotationPtr *table; /* the table of attributes */
} xmlNotationTable;
typedef xmlNotationTable *xmlNotationTablePtr;
@ -35,7 +51,7 @@ typedef xmlNotationTable *xmlNotationTablePtr;
typedef struct xmlElementTable {
int nb_elements; /* number of elements stored */
int max_elements; /* maximum number of elements */
xmlElementPtr table; /* the table of elements */
xmlElementPtr *table; /* the table of elements */
} xmlElementTable;
typedef xmlElementTable *xmlElementTablePtr;
@ -49,13 +65,13 @@ typedef xmlElementTable *xmlElementTablePtr;
typedef struct xmlAttributeTable {
int nb_attributes; /* number of attributes stored */
int max_attributes; /* maximum number of attributes */
xmlAttributePtr table; /* the table of attributes */
xmlAttributePtr *table; /* the table of attributes */
} xmlAttributeTable;
typedef xmlAttributeTable *xmlAttributeTablePtr;
/* Notation */
xmlNotationPtr xmlAddNotationDecl(xmlDtdPtr dtd, const CHAR *name,
const CHAR *PublicID, const CHAR *SystemID);
xmlNotationPtr xmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd,
const CHAR *name, const CHAR *PublicID, const CHAR *SystemID);
xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table);
void xmlFreeNotationTable(xmlNotationTablePtr table);
void xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table);
@ -66,8 +82,8 @@ xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
void xmlFreeElementContent(xmlElementContentPtr cur);
/* Element */
xmlElementPtr xmlAddElementDecl(xmlDtdPtr dtd, const CHAR *name, int type,
xmlElementContentPtr content);
xmlElementPtr xmlAddElementDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd,
const CHAR *name, int type, xmlElementContentPtr content);
xmlElementTablePtr xmlCopyElementTable(xmlElementTablePtr table);
void xmlFreeElementTable(xmlElementTablePtr table);
void xmlDumpElementTable(xmlBufferPtr buf, xmlElementTablePtr table);
@ -78,11 +94,32 @@ void xmlFreeEnumeration(xmlEnumerationPtr cur);
xmlEnumerationPtr xmlCopyEnumeration(xmlEnumerationPtr cur);
/* Attribute */
xmlAttributePtr xmlAddAttributeDecl(xmlDtdPtr dtd, const CHAR *elem,
const CHAR *name, int type, int def,
xmlAttributePtr xmlAddAttributeDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd,
const CHAR *elem, const CHAR *name, int type, int def,
const CHAR *defaultValue, xmlEnumerationPtr tree);
xmlAttributeTablePtr xmlCopyAttributeTable(xmlAttributeTablePtr table);
void xmlFreeAttributeTable(xmlAttributeTablePtr table);
void xmlDumpAttributeTable(xmlBufferPtr buf, xmlAttributeTablePtr table);
/**
* The public function calls related to validity checking
*/
int xmlValidateRoot(xmlValidCtxtPtr ctxt, xmlDocPtr doc);
int xmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
xmlElementPtr elem);
int xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
xmlAttributePtr attr);
int xmlValidateNotationDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
xmlNotationPtr nota);
int xmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd);
int xmlValidateDocument(xmlValidCtxtPtr ctxt, xmlDocPtr doc);
int xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem);
int xmlValidateOneElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
xmlNodePtr elem);
int xmlValidateOneAttribute(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
xmlNodePtr elem, xmlAttrPtr attr, const CHAR *value);
int xmlIsMixedElement(xmlDocPtr doc, const CHAR *name);
#endif /* __XML_VALID_H__ */

45
xmlIO.c
View File

@ -6,6 +6,10 @@
* Daniel.Veillard@w3.org
*/
/*
* TODO: plug-in a generic transfer library, like libwww if available
*/
#include "config.h"
#include <sys/types.h>
@ -18,6 +22,7 @@
#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
#include <string.h>
#include "xmlIO.h"
@ -319,3 +324,43 @@ xmlParserInputBufferRead(xmlParserInputBufferPtr in, int len) {
return(xmlParserInputBufferGrow(in, len));
}
/*
* xmlParserGetDirectory:
* @filename: the path to a file
*
* lookup the directory for that file
*
* Returns a new allocated string containing the directory, or NULL.
*/
char *
xmlParserGetDirectory(const char *filename) {
char *ret = NULL;
char dir[1024];
char *cur;
char sep = '/';
if (filename == NULL) return(NULL);
#ifdef WIN32
sep = '\\';
#endif
strncpy(dir, filename, 1023);
dir[1023] = 0;
cur = &dir[strlen(dir)];
while (cur > dir) {
if (*cur == sep) break;
cur --;
}
if (*cur == sep) {
if (cur == dir) dir[1] = 0;
else *cur = 0;
ret = strdup(dir);
} else {
if (getcwd(dir, 1024) != NULL) {
dir[1023] = 0;
ret = strdup(dir);
}
}
return(ret);
}

View File

@ -45,6 +45,7 @@ int xmlParserInputBufferRead(xmlParserInputBufferPtr in, int len);
int xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len);
void xmlFreeParserInputBuffer(xmlParserInputBufferPtr in);
char *xmlParserGetDirectory(const char *filename);
#ifdef __cplusplus
}

218
xpath.c
View File

@ -13,17 +13,25 @@
* Author: Daniel.Veillard@w3.org
*/
#include <config.h>
#include <malloc.h>
#ifdef HAVE_MATH_H
#include <math.h>
#endif
#ifdef HAVE_MATH_H
#include <float.h>
#endif
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
#ifdef HAVE_NAN_H
#include <nan.h>
#endif
#include <stdio.h>
#include "tree.h"
#include "xpath.h"
#include "parserInternals.h"
/*
* TODO: create a pseudo document element and affect it as the
* actual root.
*/
/*
* Setup stuff for floating point
*/
@ -31,6 +39,70 @@ double xmlXPathNAN = 0;
double xmlXPathPINF = 1;
double xmlXPathMINF = -1;
#ifndef isinf
#ifndef HAVE_ISINF
#if HAVE_FPCLASS
int isinf(double d) {
fpclass_t type = fpclass(d);
switch (type) {
case FP_NINF:
return(-1);
case FP_PINF:
return(1);
default:
return(0);
}
return(0);
}
#elif defined(HAVE_FP_CLASS) || defined(HAVE_FP_CLASS_D)
#if HAVE_FP_CLASS_H
#include <fp_class.h>
#endif
int isinf(double d) {
#if HAVE_FP_CLASS
int fpclass = fp_class(d);
#else
int fpclass = fp_class_d(d);
#endif
if (fpclass == FP_POS_INF)
return(1);
if (fpclass == FP_NEG_INF)
return(-1);
return(0);
}
#elif defined(HAVE_CLASS)
int isinf(double d) {
int fpclass = class(d);
if (fpclass == FP_PLUS_INF)
return(1);
if (fpclass == FP_MINUS_INF)
return(-1);
return(0);
}
#elif defined(finite) || defined(HAVE_FINITE)
int isinf(double x) { return !finite(x) && x==x; }
#endif /* ! HAVE_FPCLASS */
#endif /* ! HAVE_ISINF */
#endif /* ! defined(isinf) */
#ifndef isnan
#ifndef HAVE_ISNAN
#ifdef HAVE_ISNAND
#define isnan(f) isnand(f)
#endif /* HAVE_iSNAND */
#endif /* ! HAVE_iSNAN */
#endif /* ! defined(isnan) */
/**
* xmlXPathInit:
*
@ -87,7 +159,7 @@ extern int name##Push(xmlXPathParserContextPtr ctxt, type value) { \
ctxt->name##Tab = (void *) realloc(ctxt->name##Tab, \
ctxt->name##Max * sizeof(ctxt->name##Tab[0])); \
if (ctxt->name##Tab == NULL) { \
fprintf(xmlXPathDebug, "realloc failed !\n"); \
fprintf(xmlXPathDebug, "realloc failed !\n"); \
exit(1); \
} \
} \
@ -458,7 +530,9 @@ xmlXPathDebugNodeSet(FILE *output, xmlNodeSetPtr obj) {
fprintf(output, " NULL !\n");
return;
}
if (obj->nodeTab[i]->name == NULL)
if (obj->nodeTab[i]->type == XML_DOCUMENT_NODE)
fprintf(output, " /");
else if (obj->nodeTab[i]->name == NULL)
fprintf(output, " noname!");
else fprintf(output, " %s", obj->nodeTab[i]->name);
}
@ -866,8 +940,6 @@ xmlXPathEqualValues(xmlXPathObjectPtr arg1, xmlXPathObjectPtr arg2) {
* xmlXPathCompareValues:
* @inf: less than (1) or greater than (2)
* @strict: is the comparison strict
* @arg1: first XPath object argument
* @arg2: second XPath object argument
*
* Implement the compare operation on XPath objects:
* @arg1 < @arg2 (1, 1, ...
@ -875,11 +947,9 @@ xmlXPathEqualValues(xmlXPathObjectPtr arg1, xmlXPathObjectPtr arg2) {
* @arg1 > @arg2 (0, 1, ...
* @arg1 >= @arg2 (0, 0, ...
*
* Returns 0 or 1 depending on the results of the test.
*/
int
xmlXPathCompareValues(int inf, int strict, xmlXPathObjectPtr arg1,
xmlXPathObjectPtr arg2) {
xmlXPathCompareValues(int inf, int strict) {
TODO /* compare */
return(0);
}
@ -1064,8 +1134,13 @@ xmlXPathNextSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
*/
xmlNodePtr
xmlXPathNextChild(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
if (cur == NULL)
if (cur == NULL) {
if (ctxt->context->node == (xmlNodePtr) ctxt->context->doc)
return(ctxt->context->doc->root);
return(ctxt->context->node->childs);
}
if (ctxt->context->node->type == XML_DOCUMENT_NODE)
return(NULL);
return(cur->next);
}
@ -1080,8 +1155,11 @@ xmlXPathNextChild(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
*/
xmlNodePtr
xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
if (cur == NULL)
if (cur == NULL) {
if (ctxt->context->node == (xmlNodePtr) ctxt->context->doc)
return(ctxt->context->doc->root);
return(ctxt->context->node->childs);
}
if (cur->childs != NULL) return(cur->childs);
if (cur->next != NULL) return(cur->next);
@ -1114,6 +1192,8 @@ xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
if (cur == NULL)
return(ctxt->context->node);
if (cur == (xmlNodePtr) ctxt->context->doc)
return(ctxt->context->doc->root);
if (cur->childs != NULL) return(cur->childs);
if (cur->next != NULL) return(cur->next);
@ -1144,8 +1224,11 @@ xmlXPathNextParent(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
* the parent of an attribute or namespace node is the element
* to which the attribute or namespace node is attached
*/
if (cur == NULL)
if (cur == NULL) {
if (ctxt->context->node->parent == NULL)
return((xmlNodePtr) ctxt->context->doc);
return(ctxt->context->node->parent);
}
return(NULL);
}
@ -1168,9 +1251,15 @@ xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
* the parent of an attribute or namespace node is the element
* to which the attribute or namespace node is attached
*/
if (cur == NULL)
if (cur == NULL) {
if (ctxt->context->node->parent == NULL)
return((xmlNodePtr) ctxt->context->doc);
return(ctxt->context->node->parent);
if (cur == ctxt->context->doc->root) return(NULL);
}
if (cur == ctxt->context->doc->root)
return((xmlNodePtr) ctxt->context->doc);
if (cur == (xmlNodePtr) ctxt->context->doc)
return(NULL);
return(cur->parent);
}
@ -1194,7 +1283,10 @@ xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
*/
if (cur == NULL)
return(ctxt->context->node);
if (cur == ctxt->context->doc->root) return(NULL);
if (cur == ctxt->context->doc->root)
return((xmlNodePtr) ctxt->context->doc);
if (cur == (xmlNodePtr) ctxt->context->doc)
return(NULL);
return(cur->parent);
}
@ -1209,6 +1301,8 @@ xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
*/
xmlNodePtr
xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
if (cur == (xmlNodePtr) ctxt->context->doc)
return(NULL);
if (cur == NULL)
return(ctxt->context->node->next);
return(cur->next);
@ -1226,6 +1320,8 @@ xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
*/
xmlNodePtr
xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
if (cur == (xmlNodePtr) ctxt->context->doc)
return(NULL);
if (cur == NULL)
return(ctxt->context->node->prev);
return(cur->prev);
@ -1244,6 +1340,8 @@ xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
*/
xmlNodePtr
xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
if (cur == (xmlNodePtr) ctxt->context->doc)
return(NULL);
if (cur == NULL)
return(ctxt->context->node->next);; /* !!!!!!!!! */
if (cur->childs != NULL) return(cur->childs);
@ -1274,6 +1372,8 @@ xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
*/
xmlNodePtr
xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
if (cur == (xmlNodePtr) ctxt->context->doc)
return(NULL);
if (cur == NULL)
return(ctxt->context->node->prev); /* !!!!!!!!! */
if (cur->last != NULL) return(cur->last);
@ -1515,14 +1615,19 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, int axis,
TODO /* NS search */
break;
case NODE_TEST_NAME:
if (!xmlStrcmp(name, cur->name) &&
(((prefix == NULL) ||
((cur->ns != NULL) &&
(!xmlStrcmp(prefix, cur->ns->href)))))) {
switch (cur->type) {
case XML_ELEMENT_NODE:
if (!xmlStrcmp(name, cur->name) &&
(((prefix == NULL) ||
((cur->ns != NULL) &&
(!xmlStrcmp(prefix, cur->ns->href)))))) {
#ifdef DEBUG_STEP
n++;
n++;
#endif
xmlXPathNodeSetAdd(ret, cur);
xmlXPathNodeSetAdd(ret, cur);
}
default:
break;
}
break;
@ -1553,8 +1658,8 @@ void
xmlXPathRoot(xmlXPathParserContextPtr ctxt) {
if (ctxt->context->nodelist != NULL)
xmlXPathFreeNodeSet(ctxt->context->nodelist);
ctxt->context->node = ctxt->context->doc->root;
ctxt->context->nodelist = xmlXPathNodeSetCreate(ctxt->context->doc->root);
ctxt->context->node = (xmlNodePtr) ctxt->context->doc;
ctxt->context->nodelist = xmlXPathNodeSetCreate(ctxt->context->node);
}
/**
@ -3125,8 +3230,7 @@ xmlXPathEvalRelationalExpr(xmlXPathParserContextPtr ctxt) {
(CUR == '>') ||
((CUR == '<') && (NXT(1) == '=')) ||
((CUR == '>') && (NXT(1) == '='))) {
xmlXPathObjectPtr arg1, arg2, res;
int inf, strict, equal;
int inf, strict;
if (CUR == '<') inf = 1;
else inf = 0;
@ -3136,13 +3240,7 @@ xmlXPathEvalRelationalExpr(xmlXPathParserContextPtr ctxt) {
if (!strict) NEXT;
xmlXPathEvalAdditiveExpr(ctxt);
CHECK_ERROR;
arg2 = valuePop(ctxt);
arg1 = valuePop(ctxt);
equal = xmlXPathCompareValues(inf, strict, arg1, arg2);
res = xmlXPathNewBoolean(equal);
valuePush(ctxt, res);
xmlXPathFreeObject(arg1);
xmlXPathFreeObject(arg2);
xmlXPathCompareValues(inf, strict);
}
}
@ -3460,6 +3558,55 @@ xmlXPathEvalBasis(xmlXPathParserContextPtr ctxt) {
if (name != NULL)
free(name);
name = xmlXPathParseQName(ctxt, &prefix);
if (name == NULL) {
ERROR(XPATH_EXPR_ERROR);
}
type = xmlXPathGetNameType(ctxt, name);
switch (type) {
/*
* Simple case: no axis seach all given node types.
*/
case NODE_TYPE_COMMENT:
if ((CUR != '(') || (NXT(1) != ')')) break;
SKIP(2);
nodetest = NODE_TEST_TYPE;
nodetype = XML_COMMENT_NODE;
goto search_nodes;
case NODE_TYPE_TEXT:
if ((CUR != '(') || (NXT(1) != ')')) break;
SKIP(2);
nodetest = NODE_TEST_TYPE;
nodetype = XML_TEXT_NODE;
goto search_nodes;
case NODE_TYPE_NODE:
if ((CUR != '(') || (NXT(1) != ')')) {
nodetest = NODE_TEST_NAME;
break;
}
SKIP(2);
nodetest = NODE_TEST_TYPE;
nodetype = XML_ELEMENT_NODE;
goto search_nodes;
case NODE_TYPE_PI:
if (CUR != '(') break;
if (NXT(1) != ')') {
/*
* Specific case: search a PI by name.
*/
SKIP(2);
nodetest = NODE_TEST_PI;
xmlXPathEvalLiteral(ctxt);
CHECK_ERROR;
if (CUR != ')')
ERROR(XPATH_UNCLOSED_ERROR);
xmlXPathSearchPI(ctxt, 0);
return;
}
SKIP(2);
nodetest = NODE_TEST_TYPE;
nodetype = XML_PI_NODE;
goto search_nodes;
}
nodetest = NODE_TEST_NAME;
}
} else if ((CUR == ':') && (nodetest == NODE_TEST_NAME)) {
@ -3618,7 +3765,8 @@ xmlXPathEvalLocationPath(xmlXPathParserContextPtr ctxt) {
} else if (CUR == '/') {
NEXT;
xmlXPathRoot(ctxt);
xmlXPathEvalRelativeLocationPath(ctxt);
if (CUR != 0)
xmlXPathEvalRelativeLocationPath(ctxt);
} else {
xmlXPathEvalRelativeLocationPath(ctxt);
}