Re: Node order of XPath result
[email protected] Wed, 28 Jan 2015 01:00:08 -0500 (EST)
| Newsgroups | gmane.lisp.scheme.ssax-sxml |
|---|---|
| Message-ID | <[email protected]> |
Hello!
I have taken a brief look at the problem (too late, sorry). I
wanted to see if this a problem with SSAX. The document in question,
the IMDB web page, looks like XHTML, that is, XML. At least it uses
the XML style for no-content tags like <link ... />. But XML it is
not. SSAX has kept complaining: first it found a bare '&' character
(such characters are prohibited anywhere except in CDATA). When I
removed all scripts, SSAX started complaining about an unclosed 'div'
tag. Out of curiosity I ran xmllint on the file; there were so many
errors that they overflowed the tmux scrolling buffer. There were all
sorts of errors: bare ampersand, unclosed tags, mismatched tags, etc.
Here is a very common problem:
<img height="113" width="76" alt="The Reader" title="The Reader"src="http.."/>
Notice that there is no space before src. This problem confuses
xmllint, which then complains about the unclosed img tag. This is
symptomatic -- if a parser tries to recover from an error, it may get
confused further. So, the parser you are using may have gotten
confused. I would not blame the parser too much: if the document is
ill-formed, producing any parse is best effort and the outcome
is not guaranteed.
Certainly you cannot use SSAX to parse the file, because SSAX follows
the Recommendation and reports the errors that it is supposed to
report. I have tried to create a simple document with the h1 element
in question:
<!DOCTYPE html>
<html
xmlns:og="http://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>Vicky Cristina Barcelona (2008) - IMDb</title>
</head>
<body id="styleguide-v2" class="fixed">
<h1 class="header"> <span class="itemprop" itemprop="name">Vicky Cristina Barcelona</span>
<span class="nobr">(<a href="/year/2008/?ref_=tt_ov_inf"
>2008</a>)</span>
</h1>
</body></html>
SSAX parsed it without problem, producing
(*TOP*
(html
(head (title "Vicky Cristina Barcelona (2008) - IMDb"))
(body
(@ (id "styleguide-v2") (class "fixed"))
(h1 (@ (class "header"))
(span
(@ (itemprop "name") (class "itemprop"))
"Vicky Cristina Barcelona")
(span
(@ (class "nobr"))
"("
(a (@ (href "/year/2008/?ref_=tt_ov_inf")) "2008")
")")))))
which seems the correct parse. You may try your query
on the above simple document. If Dmitry reads this, perhaps he has
further suggestions.
Cheers,
Oleg
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/