Commit Graph

51 Commits

Author SHA1 Message Date
Michaël Van Canneyt
505b66b892 * Test program 2023-07-15 18:22:39 +02:00
Michaël Van Canneyt
827606f114 * PChar -> PAnsiChar 2023-07-15 18:22:37 +02:00
marco
869d24f7d1 * spelling mistakes fpc repo part, mantis #30233
git-svn-id: trunk@33882 -
2016-06-02 20:01:09 +00:00
michael
cf6c07df4f * Small test program for xmlconf
git-svn-id: trunk@30324 -
2015-03-25 17:53:14 +00:00
sergei
4b421c66b6 + Unit tests for TXMLReader-based XML parsing classes.
git-svn-id: trunk@27122 -
2014-03-13 00:30:57 +00:00
sergei
7cc9e5c18c * Provide distinct error messages.
git-svn-id: trunk@27121 -
2014-03-13 00:28:33 +00:00
sergei
8afc5b8ebf + Basic implementation of TXPathNSResolver class, Mantis #25183.
git-svn-id: trunk@25814 -
2013-10-18 08:36:19 +00:00
sergei
c7259969ce + fcl-xml, implemented TDOMNode.BaseURI property.
* Moved element loading procedure from xmlread.pp to dom.pp, speeds things up a bit.

git-svn-id: trunk@20558 -
2012-03-21 22:19:27 +00:00
sergei
134e5167f1 * fcl-xml testing suite, working around excessive string conversions by using new method assertEqualsW to compare wide strings. Since TTestCase.assertEquals method already exists with ansistring arguments, and its first argument is a literal in most cases, overloading does not help here.
git-svn-id: trunk@20442 -
2012-02-29 09:28:03 +00:00
sergei
6adf381867 * fcl-xml, upgrade to comply with XML 1.0 Fifth Edition. This makes naming rules for xml 1.0 identical to ones for xml 1.1.
git-svn-id: trunk@20422 -
2012-02-24 06:25:32 +00:00
sergei
92e0f43f5d * Changed Utf8String to AnsiString, fixes compilation after merging of cpstring.
git-svn-id: trunk@19639 -
2011-11-14 22:58:48 +00:00
sergei
70bc36da85 + Implemented TDOMDocument.xmlStandalone property
git-svn-id: trunk@18033 -
2011-07-29 04:03:30 +00:00
sergei
2786259d77 dom.pp:
* r15443 changed the node class with biggest instance size from TDOMAttr to TDOMEntity. Changed that in TDOMDocument constructor, too. Otherwise nodes created with TDOMEntity.CloneNode will leak (they cannot be inserted into tree).
* Do not restore default attributes during document destruction.
* Also added a general check that raises exception if someone tries to allocate from node pool during destruction.
* Fixed replaceChild() method: it was deleting node if that node was replaced by itself.
+ Test for replaceChild.

git-svn-id: trunk@16010 -
2010-09-19 14:11:20 +00:00
sergei
22038d7db6 + XPath test suite, implemented possibility to use a specified context node instead of fixed root element.
* enabled expressions which start with a FilterNode.
+ added a test for ancestor:: axis of attribute.

git-svn-id: trunk@15650 -
2010-07-28 12:24:27 +00:00
sergei
5352b78c4a * XPath, fixed parsing of 'prefix:*' node tests:
o The prefix to resolve should not include following ':*' characters
  o NextToken changes CurTokenString, so NextToken must be after reading CurTokenString.
  o Added a test for that
* XPath test suite, fixed comparison of numeric result (it is quite tricky in presence of NaNs).

git-svn-id: trunk@15639 -
2010-07-26 16:35:35 +00:00
sergei
ead5707179 + Enumeration type for XML version
+ Implemented DOM level 3 properties xmlVersion and xmlEncoding for both TDOMDocument and TDOMEntity classes. Also declared property inputEncoding for these classes.
* Non-conformant TXMLDocument.Encoding has been deprecated; it is now an alias for xmlEncoding property.
* TDOMDocument and TDOMEntity now share a common ancestor, TDOMNode_TopLevel.
* api.xml: enabled testing for the new properties

git-svn-id: trunk@15443 -
2010-06-15 19:36:22 +00:00
sergei
8f29def76e * xmlread.pp: when IgnoreComments=True, merge together text nodes that precede and follow the skipped comment. With this fix, the reader finally produces normalized documents in all modes, so remove the corresponding cheat from testing program (xmlts.pp).
git-svn-id: trunk@15442 -
2010-06-15 16:13:42 +00:00
sergei
3bb9bfd2b8 * XPath, fixed parent axis of attribute nodes: it must consist of the owner element of an attribute.
+ Tests

git-svn-id: trunk@15439 -
2010-06-14 21:15:53 +00:00
sergei
1ed130e2e1 * Fixed XPath functions name() and local-name(), which should behave different from DOM properties of the same names. name() is empty for text, comment and document nodes. local-name() is the same as name() for non-prefixed attributes and processing instructions.
+ Another dozen of tests.

git-svn-id: trunk@15438 -
2010-06-14 17:21:35 +00:00
sergei
255c14fc4d * TDOMElement.RemoveAttributeNode() was not resetting OwnerElement property of the removed attribute to nil, fixed and added a test case.
git-svn-id: trunk@14351 -
2009-12-07 16:16:10 +00:00
sergei
0c50cfe10a + Initial implementation of property TDOMParseOptions.CanonicalForm. The only thing it does yet is ignoring the DTD.
* Fixed relevant tests.

git-svn-id: trunk@13914 -
2009-10-20 22:09:51 +00:00
sergei
013fbb8566 Fixed memory leaks in tests.
git-svn-id: trunk@13878 -
2009-10-16 22:50:46 +00:00
sergei
f387d7cb2d * Only EXMLReadError is expected to be thrown from a negative test, any other exception is unexpected and should render the test as failed.
git-svn-id: trunk@13860 -
2009-10-15 21:27:31 +00:00
sergei
a283bc4f46 xpath.pp:
* Progress with namespace support. Resolve namespace prefixed while parsing, compare namespaceURI/localNames while evaluating. Existing tests for namespace-uri(), local-name() and name() now all pass, but resolving interface isn't ready for general use yet.
* Fixed name() to default to context node if argument is omitted.

xpathts.pp:
+ support for prefix resolving while testing.

git-svn-id: trunk@13846 -
2009-10-11 15:04:33 +00:00
sergei
0c41473f7b Two more DOM Level 3 functions + tests for them:
+ TDOMNode.lookupPrefix()
+ TDOMNode.isDefaultNamespaceURI()

git-svn-id: trunk@13800 -
2009-10-03 23:35:20 +00:00
sergei
eb18aa8831 + 3 more tests for verifying the namespace fixup
git-svn-id: trunk@13788 -
2009-10-01 19:14:36 +00:00
sergei
d2c3ab0730 * r13729 was broken due to missing typecast, shame on me. Fixed.
git-svn-id: trunk@13787 -
2009-10-01 19:11:47 +00:00
sergei
fc34dc84ff domunit.pp:
+ Added TDOMTestBase.LoadStringData method, allows loading documents from string.
* Don't return empty string from GetResourceURI when file doesn't exist. Thus we can see the problematic filename in the test output.

+ Added extras.pp, contains a few tests not present in w3.org test suite.
+ Added extras2.pp, contains some tests ported by hand because no automatic conversion possible yet. It addresses namespace fixup during serialization and canonical-form issues.

README_DOM.txt: updated to reflect the added units.

git-svn-id: trunk@13729 -
2009-09-17 09:58:15 +00:00
sergei
a9d9841eee * XPath: number-to-string conversion is now compliant to the specs (no scientific notation, decimal separator is a hardcoded period, correct output values for INF/NAN) + tests.
git-svn-id: trunk@13389 -
2009-07-15 09:56:48 +00:00
sergei
106a605e05 xpath.pp:
- Removed (made abstract) default implementations of TXPathVariable.AsText(), AsNumber() and
  AsBoolean(). These methods are overriden by all TXPathVariable descendants, therefore in
  TXPathVariable itself they are dead and only increase executable size.
- Removed debug statement committed by accident in r13256.

tests/xpathts.pp:
* Annotated some tests, added a few tests for name(), namespace-uri() and local-name().

git-svn-id: trunk@13322 -
2009-06-24 19:16:33 +00:00
sergei
dbd2759da9 + Implementation of TDOMDocument.DocumentURI and TDOMAttr.IsID + tests.
git-svn-id: trunk@13291 -
2009-06-18 21:34:07 +00:00
sergei
f31d31049e Improved XPath test suite and added some more tests.
git-svn-id: trunk@13260 -
2009-06-11 19:21:37 +00:00
sergei
baa07b1a22 Bringing readme's up to date
git-svn-id: trunk@13216 -
2009-05-31 10:38:28 +00:00
sergei
466c41da12 * Added .txt extension to README_DOM (this one was missed while fixing Mantis #12358)
git-svn-id: trunk@13215 -
2009-05-31 09:14:37 +00:00
sergei
035fe43b72 Final strike for #13605:
src/dom.pp:
* GetElementsByTagName[NS] results now get cached in a hashtable. Repeated calls to
  GetElementsByTagName with same arguments return the same instance of NodeList. All NodeLists
  created during document lifetime are destroyed with the document.

src/xmlutils.pp:
* THashTable.Lookup(), changed SetString to SetLength+Move because SetString truncates on #0
+ added THashTable.RemoveData() method

tests/api.xml:
- No longer need to 'garbage collect' the NodeLists.

git-svn-id: trunk@13180 -
2009-05-20 23:08:24 +00:00
sergei
6049600ccb DOM test suite enhancements:
* Do not convert tests which request implementation attribute 'signed'='true'.
  Such tests aren't applicable to our unsigned DOM, they only cause compiler warnings
  and noise in the test report.
+ Support for default properties (obj.item(x) -> obj[x]).
+ Support black-listing of testcases. Some of them (in HTML testsuite) are easier to
  rewrite by hand than to convert.
+ Support adding certain units to 'uses' clause (e.g. HTML suite must use dom_html).

git-svn-id: trunk@13172 -
2009-05-17 22:56:51 +00:00
sergei
54b475a68b dom.pp:
* Partial fix for #13605 (fixes the issue as reported, but a fix for nodelists returned by
  GetElementsByTagName[NS] is also needed):
  - Each node which can have children has an associated instance of TDOMNodeList;
  - Other nodes are substituted by special 'null' node, having an empty child list;
  - Muiltiple calls to ChildNodes return the same instance of TDOMNodeList;
  - Calling Free on result of ChildNodes is optional; if not freed, it will be destroyed with
    the owning node.

tests/domunit.pp:
* Changed TFPObjectList to TObjectList, which has been found to destroy its elements in opposite
 order (reported as #13715). As NodeLists became owned by Document, old (FIFO) destruction order is
 causing their double destruction.

git-svn-id: trunk@13143 -
2009-05-14 21:00:29 +00:00
sergei
8c898e963a + Implements XPath function id() + test. Running the test is another story, however, because it requires parsing FilterExpr+'/'+RelativeLocationPath, which is currently not implemented.
git-svn-id: trunk@13106 -
2009-05-06 20:07:09 +00:00
sergei
e17ac308e0 Implementation of XPath function lang() + tests.
git-svn-id: trunk@13060 -
2009-04-29 17:52:39 +00:00
sergei
efcccbf895 Test suite improvements, targeted to support the HTML suite:
domunit.pp:
+ Added AssertEqualsNoCase() method.
* TDOMTestBase.Load chaned doc argument to untyped, because some tests use TDOMNode instead of a
  TDOMDocument.
* Completed the URIEquals() method; changed parameter types to PChar in order to be able to
  distinguish nil from empty string.
* Modified GetResourceURI method so it is capable to handle the directory structure of CVS
  snapshot (level2/html using data files from level1/html).

testgen.pp:
* Counterparts to changes in domunit.pp
+ Support for renaming APIs (e.g. 'type'->'htmlType')
+ Support for enforcing the correct type of function arguments (emits 'as' operator).

api.xml:
+ Added data for DOM Level3 XPath and Level2 HTML suites.

git-svn-id: trunk@13055 -
2009-04-28 19:18:07 +00:00
sergei
b02aededf8 More progress with XPath:
src/xpath.pp:

+ Implemented sum() and normalize-space() core functions.
* Rewrote comparison code, nodesets are now handled correctly (to the
  extent of the tests which I could find).
* starts-with() and contains() return True when second argument is an
  empty string - that differs from Pos() behavior.
* NaNs are propagated through mod operator, floor() and ceiling().
* Fixed memory leak caused by not releasing arguments after function
  calls.
* string-value of a nodeset is the value of its first node, not all
  nodes glued together.

tests/xpathts.pp:

+ Added 120 tests, most coming from OASIS Prototype XSLT/XPath 1.0
  conformance test suite.
+ Tests can now take an input xml data as a string.

git-svn-id: trunk@13046 -
2009-04-26 16:06:15 +00:00
michael
f641281a7e * Patch from Sergei Gorelkin:
+ added TXPathBinaryNode as a common ancestor for binary operations;
  + TXPathBooleanOpNode now handles only 'and' and 'or' operators,
    the purpose is to not evaluate the second argument if the result can
    be determined by the first argument;
  * Comparison operations moved to TXPathCompareNode and fixed
    to support INFs and NANs correctly;
  * Fixed TranslateWideString() that was not deleting characters;
  * Fixed 'substring-after' function so its result is empty when argument
    string does not contain the pattern;
  * Fixed 'round' funcion so it complies to the specs;
  * Completed implementation of 'substring' function (but surrogate pairs
    are not handled yet);
  * Mask exInvalidOp and exZeroDivide FPU exceptions while evaluating
    expressions, this ensures correct calculations with respect to INFs
    and NANs.
  + Added testsuite for xpath

git-svn-id: trunk@12961 -
2009-03-23 08:37:51 +00:00
Jonas Maebe
4bf254bc32 * added .txt extensions to all README, TODO and COPYING files
(mantis #12358)

git-svn-id: trunk@12825 -
2009-02-28 17:34:08 +00:00
michael
67f56b7adf * Patch from Sergei Gorelkin:
src/xmlread.pp, src/dom.pp
  * Improvements to attribute processing: attributes are now validated as
    they come. This enables reporting of the corresponding validation
    errors at correct positions (previously everything was reported at the
    end of element start-tag).
  * Search for a declaration for attribute, not for an attribute
    corresponding to the declaration. This reduces number of lookups
    (because unspecified attributes are not searched) and obsoletes the
    need in FDeclared field on every attribute.

  tests/domunit.pp, tests/testgen.pp:

  * Various improvements required to support converting of the
    DOM level 3 XPath module.

git-svn-id: trunk@12026 -
2008-11-04 18:33:05 +00:00
michael
213f8a41c7 * Large patch from Sergei Gorelkin:
xmlutils.pp, names.inc:
    * exclude colon from the NameChar bitmap and handle it in code.

  dom.pp:
    + TDOMText.IsElementContentWhitespace now implemented completely.
    * Attributes created by TDOMElement.SetAttribute get their
     OwnerElement property assigned properly
    * Attribute replaced by TDOMNamedNodeMap.SetNamedItem get their
     OwnerElement reset to nil
    * TDOMElement.SetAttributeNode does not destroy the attribute when it
     is being replaced by itself
    * Most node boolean properties collected into a single FFlags field
     to reduce memory requirements.

  xmlread.pp:
    + Syntax-level support of namespaces: handle colons in names, check
     correct qualified name syntax, prohibit colons in entity/notation/PI
     names and ID/IDREF attribute values (all this only happens when
     Options.Namespaces is set to True - not by default).
    * Reaching end of input while parsing the Ignore Section is a fatal
     error because parameter entities are not recognized there.
    * Reaching end of input while parsing entity value literal that was
     started in a parameter entity aborts immediately instead of hopelessly
     scanning the whole document up to its end.
    * Fixed parsing duplicate Element declarations. The content models of
     subsequent declarations are now discarded as they should - not
     appended to the existing model.
    * Fixed parsing duplicate Attlist declarations. In addition to dropping
     the attribute declaration itself, do not modify the corresponding
     element declaration and suppress 'Duplicate ID attribute' and
     'Duplicate NOTATION attribute' validation errors.
    * Fixed error position in cases when attribute value lacks the closing
     quote.
    * Some refactoring in order to reduce number of WideString vars and code
     size (some SkipX and ExpectX merged into SkipX(required: Boolean)).
    * TXMLCharSource.FLocation record replaced by single integer FLineNo
     because LinePosition is always calculated.
    * TXMLCharSource.FCursor replaced by local var.
    * TXMLReader.NameIs changed to a more general BufEquals(), it eliminates
     TXMLReader.GetString and some WideString variables.

  tests/xmlts.pp:
    * Ignored tests do not change suite conformance state.

  tests/testgen.pp
    * Added a forgotten semicolon.

git-svn-id: trunk@11869 -
2008-10-08 18:06:52 +00:00
michael
b3d983ce07 * Initial testsuite from Sergei Gorelkin
* testgen.pp - an utility to convert w3.org tests from XML format
      into fpcunit-compatible Pascal source. The official testsuite uses
      xslt for conversion, but, since there is no xslt for Pascal, and no
      xslt support in FCL yet, I wrote an utility.
    * api.xml    - API 'database', needed by testgen.
    * domunit.pp - an fpcunit extension, provides DOM-specific runtime
      support.
    * README_DOM - provides some instructions about putting it all together.

git-svn-id: trunk@11390 -
2008-07-17 14:57:31 +00:00
michael
d812fa0c92 * Patch from Sergei Gorelkin:
* excludes #$FFFE and #$FFFF from allowed XML 1.1 name chars, so
  IsXmlName result is correct when its argument comes not from the
  parser.
xmlread.pp:
+ Two new parsing options, Namespaces and ResolveExternals (not
  functional yet but needed to proceed).
* Fixed checking of WFC [28a], forces fatal error as soon as possible
  and prevents parsing of further (potentially malicious) data.
  Hopefully now it is truly compliant to the specs and not just
  satisfies the tests.
* In entity value literals, nesting is checked by entity, not by the
  input source (consistent to other places).
- Saving FCursor around attribute default value isn't necessary because
  FCursor is always nil while parsing the DTD.
* TList's changed to more lightweight TFPList's.
* Changed once more (probably the last time) recognizing the standalone
  percent sign in parameter entity declarations. Rationale is that
  FCurChar is no more out of sync with FSource.FBuf^, and therefore may
  be removed.

tests/xmlts.pp and tests/README:
+ Added support for the latest XML test suite (by skipping tests
  targeted for the upcoming fifth edition of XML specs).
+ 'Namespaces' option is passed to the parser.
* README updated with the latest testsuite URL.

git-svn-id: trunk@11303 -
2008-07-01 19:14:56 +00:00
michael
77b38b6be5 * Patch from Sergei Gorelkin:
fcl-xml/src/dom.pp: resolved a number of Level 1 conformance issues:

  * Node.Normalize always deletes empty text nodes
  * Node.Normalize is recursive into Attributes
  * Node.InsertBefore corrected exception code in case when RefChild is
    not one of node's children
  + Node.InsertBefore added missing check for possible cycle in tree
  + Node.AppendChild and Node.InsertBefore added checking type of NewChild
  + CloneNode enabled for Fragment and Entity
  - CloneNode deleted for DocumentType (w3 specs directly prohibit cloning
    it between documents, and cloning within one document is claimed
    'implementation specific' - but makes no sense).
  + Node.ImportNode is now working

  * Uncommented Level 2 node properties (NamespaceURI, localName and
    Prefix), this caused a name clash and a lot of function argument
    renames.

  fcl-xml/src/xmlutils.pp:

  + overloaded IsXmlName() that accepts PWideChars

  fcl-xml/src/xmlconf.pp

  * Applied a fix similar to xmlcfg.pp for Mantis #10554

  fcl-xml/src/xmlread.pp:

  * Major: Got errors reported at correct locations for all 1600+ negative
    tests. Easy to say, but it required modifying almost every second
    line of code.
  * TContentParticle references an existing element definition instead of
    storing its own name (this allows content model matching without
    string comparisons).
  * Resorted to old-style 'object' for TElementValidator and to plain
    procedures for decoders (allows to drop almost all related memory
    management).
  * Moved parameter entity detection from char to token level, this
    simplifies things a bit.
  + Added second level of buffering to input source (a step towards
    supporting arbitrary encodings).
  * The main parsing loop contains no implicit exception frames now.


  fcl-xml/src/xmlwrite.pp

  * Replaced the stupid indenting algorithm with a simple rule: "Do not
    write indents adjacent to text nodes". Now it does not make a mess
    out of the documents which were parsed with PreserveWhitespace=True.
  * Use specialized node properties instead of generic ones, this
    eliminates WideString copies and results in almost 2x performance
    boost in Windows.
  * Even more performance:
    * Write line endings together with indents -> twice less calls.
    * Increase slack in buffer and write strings with known length (i.e.
      most of markup) without overflow checking.

  fcl-xml/tests/xmlts.pp:

  * Use parser options instead of dedicated procedure to 'canonicalize'
    documents, the parser has become mature enough to do that.
  * Fatal error in non-valid category is a test failure, as well as
    validation error alone in not-wellformed category.

  fcl-xml/src/README

  * Brought a bit up to date

  fcl-xml/tests/README

  + Added testsuite errata/issues

git-svn-id: trunk@10314 -
2008-02-13 10:31:09 +00:00
michael
4e6cd59d8c * Patch by Sergei Gorelkin:
xmlread.pp:
  * As a step towards SAX-based validation, element content validator is
  rewritten from scratch, so it now accepts child elements one by
  one. This also enables reporting location of validation errors (however,
  most locations aren't reported correctly yet).
  * More straightforward handling of comments and PIs in internal subset.
  * Attribute text is handled separately from element text.
  * Unified handling of fatal and validation errors.

  xmlutils.pp:
  * Removed auto widechar->char conversions. These should have been a part
  of fix for #9528, but were not noticed at that moment.

  dom.pp:
  * Reworked 'ugly workarounds' in node removal code.
  + Element nodes remove themselves from document list of IDs, so no invalid pointers are left around.

  xmlts.pp:
  * Corrected validation diagnostics (display the first message and ingore subsequent ones).
  * Validation error alone in a not-well-formed case is a test failure.

git-svn-id: trunk@8896 -
2007-10-21 16:09:41 +00:00
michael
64895f6b51 * Added template and README from Sergei Gorelkin
git-svn-id: trunk@6769 -
2007-03-10 13:34:59 +00:00