Initial commit
This commit is contained in:
commit
ec49fedc45
1288 files changed
+226749
No files matched your search
+10
@@ -0,0 +1,10 @@
|
||||
# contributors sorted by whether or not they're me.
|
||||
Isaac Z. Schlueter <i@izs.me>
|
||||
Stein Martin Hustad <stein@hustad.com>
|
||||
Mikeal Rogers <mikeal.rogers@gmail.com>
|
||||
Laurie Harper <laurie@holoweb.net>
|
||||
Jann Horn <jann@Jann-PC.fritz.box>
|
||||
Elijah Insua <tmpvar@gmail.com>
|
||||
Henry Rawas <henryr@schakra.com>
|
||||
Justin Makeig <jmpublic@makeig.com>
|
||||
Mike Schilling <mike@emotive.com>
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
Copyright (c) Isaac Z. Schlueter ("Author")
|
||||
All rights reserved.
|
||||
|
||||
The BSD License
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
The file "examples/strict.dtd" is licensed by the W3C and used according
|
||||
to the terms of the W3C SOFTWARE NOTICE AND LICENSE. See LICENSE-W3C.html
|
||||
for details.
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta name="generator" content="HTML Tidy for Mac OS X (vers 31 October 2006 - Apple Inc. build 13), see www.w3.org" /><title>W3C Software Notice and License</title><link rel="stylesheet" href="/2008/site/css/minimum" type="text/css" media="handheld, all" /><style type="text/css" media="print, screen and (min-width: 481px)" xml:space="preserve">
|
||||
@import url("/2008/site/css/advanced");
|
||||
</style><link href="/2008/site/css/minimum" rel="stylesheet" type="text/css" media="handheld, only screen and (max-device-width: 480px)" /><meta name="viewport" content="width=device-width" /><link rel="stylesheet" href="/2008/site/css/print" type="text/css" media="print" /><link rel="shortcut icon" href="/2008/site/images/favicon.ico" type="image/x-icon" /></head><body id="www-w3-org" class="w3c_public"><div id="w3c_container">
|
||||
|
||||
|
||||
|
||||
<div id="w3c_mast">
|
||||
<h1 class="logo">
|
||||
<a tabindex="2" accesskey="1" href="/"><img src="/2008/site/images/logo-w3c-mobile-lg" width="90" height="53" alt="W3C" /></a>
|
||||
<span class="alt-logo">W3C</span>
|
||||
</h1>
|
||||
|
||||
<div id="w3c_nav">
|
||||
|
||||
|
||||
|
||||
<form action="/Help/search" method="get" enctype="application/x-www-form-urlencoded"><div class="w3c_sec_nav"><!-- --></div><ul class="main_nav"><li class="first-item">
|
||||
<a href="/standards/">Standards</a>
|
||||
</li><li>
|
||||
<a href="/participate/">Participate</a>
|
||||
</li><li>
|
||||
<a href="/Consortium/membership">Membership</a>
|
||||
</li><li class="last-item">
|
||||
<a href="/Consortium/">About W3C</a>
|
||||
</li><li class="search-item">
|
||||
<div id="search-form">
|
||||
<input tabindex="3" class="text" name="q" value="" title="Search" type="text" />
|
||||
<button id="search-submit" name="search-submit" type="submit"><img class="submit" src="/2008/site/images/search-button" alt="Search" width="21" height="17" /></button>
|
||||
</div>
|
||||
</li></ul></form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="w3c_main">
|
||||
<div id="w3c_logo_shadow" class="w3c_leftCol">
|
||||
<img height="32" alt="" src="/2008/site/images/logo-shadow" />
|
||||
</div>
|
||||
|
||||
<div class="w3c_leftCol"><h2 class="offscreen">Site Navigation</h2>
|
||||
<h3 class="category"><span class="ribbon"><a href="/Consortium/Legal/ipr-notice.html" title="Up to Policies and Legal Information">Policies and Legal Information <img src="/2008/site/images/header-link" alt="Header link" width="13" height="13" class="header-link" /></a></span></h3>
|
||||
<ul class="theme">
|
||||
<li><a href="/Consortium/Legal/2008/04-testsuite-copyright.html">Licenses for W3C Test Suites</a></li>
|
||||
<li><a href="/2004/10/27-testcases.html">Policies for Contribution of Test Cases to W3C</a></li>
|
||||
<li><a href="/Consortium/Legal/IPR-FAQ-20000620.html">Intellectual Rights FAQ</a></li>
|
||||
<li><a href="/Consortium/Legal/privacy-statement-20000612.html">W3C Privacy Statements</a></li>
|
||||
<li><a href="/Consortium/Legal/2002/copyright-documents-20021231.html">W3C Document License</a></li>
|
||||
<li><a href="/Consortium/Legal/2002/trademarks-20021231.html">W3C Trademarks and Generic Terms</a></li>
|
||||
<li><a href="/Consortium/Legal/2002/trademark-license-20021231.html">W3C® Trademark and Service Mark License</a></li>
|
||||
<li><a class="current">W3C Software Notice and License</a></li>
|
||||
<li><a href="/Consortium/Legal/2002/collaborators-agreement-20021231.html">W3C Invited Expert and Collaborators Agreement</a></li>
|
||||
<li><a href="/Consortium/Persistence.html">W3C URI Persistence Policy</a></li>
|
||||
<li><a href="/1999/10/21-mirroring-policy.html">Mirroring the W3C Site</a></li>
|
||||
<li><a href="/Consortium/Legal/2006/08-copyright-translations.html">Translations of the Copyright Notice</a></li>
|
||||
</ul>
|
||||
<br /></div>
|
||||
<div class="w3c_mainCol">
|
||||
<div id="w3c_crumbs">
|
||||
<div id="w3c_crumbs_frame">
|
||||
<ul class="bct"> <!-- .bct / Breadcrumbs -->
|
||||
<li class="skip"><a tabindex="1" accesskey="2" title="Skip to content (e.g., when browsing via audio)" href="#w3c_content_body">Skip</a></li>
|
||||
<li><a href="/">W3C</a> <span class="cr">»</span> </li>
|
||||
<li><a href="/Consortium/">About W3C</a> <span class="cr">»</span> </li>
|
||||
<li><a href="/Consortium/facts.html">Facts About W3C</a> <span class="cr">»</span> </li>
|
||||
<li><a href="/Consortium/Legal/ipr-notice.html">Policies and Legal Information</a> <span class="cr">»</span> </li>
|
||||
<li class="current">W3C Software Notice and License</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="title">W3C Software Notice and License</h1>
|
||||
<div id="w3c_content_body">
|
||||
<div class="line">
|
||||
<p class="intro tPadding">This work (and included software, documentation such as READMEs, or other
|
||||
related items) is being provided by the copyright holders under the following
|
||||
license.</p>
|
||||
<h2>License</h2>
|
||||
|
||||
<p class="tPadding">
|
||||
By obtaining, using and/or copying this work, you (the licensee)
|
||||
agree that you have read, understood, and will comply with the following
|
||||
terms and conditions.</p>
|
||||
|
||||
<p>Permission to copy, modify, and distribute this software and its
|
||||
documentation, with or without modification, for any purpose and without
|
||||
fee or royalty is hereby granted, provided that you include the following on
|
||||
ALL copies of the software and documentation or portions thereof, including
|
||||
modifications:</p>
|
||||
|
||||
<ul class="show_items"><li>The full text of this NOTICE in a location viewable to users of the
|
||||
redistributed or derivative work.</li><li>Any pre-existing intellectual property disclaimers, notices, or terms
|
||||
and conditions. If none exist, the <a href="copyright-software-short-notice-20021231.html">W3C Software Short
|
||||
Notice</a> should be included (hypertext is preferred, text is permitted)
|
||||
within the body of any redistributed or derivative code.</li><li>Notice of any changes or modifications to the files, including the date
|
||||
changes were made. (We recommend you provide URIs to the location from
|
||||
which the code is derived.)</li></ul>
|
||||
|
||||
<h2>Disclaimers</h2>
|
||||
|
||||
<p>THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS
|
||||
MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR
|
||||
PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE
|
||||
ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.</p>
|
||||
|
||||
<p>COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR
|
||||
DOCUMENTATION.</p>
|
||||
|
||||
<p>The name and trademarks of copyright holders may NOT be used in
|
||||
advertising or publicity pertaining to the software without specific, written
|
||||
prior permission. Title to copyright in this software and any associated
|
||||
documentation will at all times remain with copyright holders.</p>
|
||||
|
||||
<h2>Notes</h2>
|
||||
|
||||
<p>This version: http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231</p>
|
||||
|
||||
<p>This formulation of W3C's notice and license became active on December 31
|
||||
2002. This version removes the copyright ownership notice such that this
|
||||
license can be used with materials other than those owned by the W3C,
|
||||
reflects that ERCIM is now a host of the W3C, includes references to this
|
||||
specific dated version of the license, and removes the ambiguous grant of
|
||||
"use". Otherwise, this version is the same as the <a href="http://www.w3.org/Consortium/Legal/copyright-software-19980720">previous
|
||||
version</a> and is written so as to preserve the <a href="http://www.gnu.org/philosophy/license-list.html#GPLCompatibleLicenses">Free
|
||||
Software Foundation's assessment of GPL compatibility</a> and <a href="http://www.opensource.org/licenses/W3C.php">OSI's certification</a>
|
||||
under the <a href="http://www.opensource.org/docs/definition.php">Open Source
|
||||
Definition</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div><div id="w3c_footer">
|
||||
<div id="w3c_footer-inner">
|
||||
<h2 class="offscreen">Footer Navigation</h2>
|
||||
<div class="w3c_footer-nav">
|
||||
<h3>Navigation</h3>
|
||||
<ul class="footer_top_nav"><li>
|
||||
<a href="/">Home</a>
|
||||
</li><li>
|
||||
<a href="/standards/">Standards</a>
|
||||
</li><li>
|
||||
<a href="/participate/">Participate</a>
|
||||
</li><li>
|
||||
<a href="/Consortium/membership">Membership</a>
|
||||
</li><li class="last-item">
|
||||
<a href="/Consortium/">About W3C</a>
|
||||
</li></ul>
|
||||
</div>
|
||||
<div class="w3c_footer-nav">
|
||||
<h3>Contact W3C</h3>
|
||||
<ul class="footer_bottom_nav"><li>
|
||||
<a href="/Consortium/contact">Contact</a>
|
||||
</li><li>
|
||||
<a accesskey="0" href="/Help/">Help and FAQ</a>
|
||||
</li><li>
|
||||
<a href="/Consortium/sponsor/">Sponsor / Donate</a>
|
||||
</li><li>
|
||||
<a href="/Consortium/siteindex">Site Map</a>
|
||||
</li><li>
|
||||
<address id="w3c_signature">
|
||||
<a href="http://lists.w3.org/Archives/Public/site-comments/">Feedback</a></address>
|
||||
</li></ul>
|
||||
</div>
|
||||
<div class="w3c_footer-nav">
|
||||
<h3>W3C Updates</h3>
|
||||
<ul class="footer_follow_nav"><li>
|
||||
<a href="http://twitter.com/W3C" title="Follow W3C on Twitter">
|
||||
<img src="/2008/site/images/twitter-bird" alt="Twitter" width="78" height="83" class="social-icon" />
|
||||
</a>
|
||||
<a href="http://identi.ca/w3c" title="See W3C on Identica">
|
||||
<img src="/2008/site/images/identica-logo" alt="Identica" width="91" height="83" class="social-icon" />
|
||||
</a>
|
||||
</li></ul>
|
||||
</div>
|
||||
<p class="copyright">Copyright © 2012 W3C <sup>®</sup> (<a href="http://www.csail.mit.edu/">
|
||||
<acronym title="Massachusetts Institute of Technology">MIT</acronym>
|
||||
</a>, <a href="http://www.ercim.org/">
|
||||
<acronym title="European Research Consortium for Informatics and Mathematics"> ERCIM</acronym>
|
||||
</a>, <a href="http://www.keio.ac.jp/">Keio</a>) <a href="/Consortium/Legal/ipr-notice">Usage policies apply</a>.</p>
|
||||
</div>
|
||||
</div><!-- Generated from data/scripts.php, ../../smarty/{scripts.tpl} --><!-- At the bottom for performance reasons --><div id="w3c_scripts">
|
||||
<script type="text/javascript" src="/2008/site/js/main" xml:space="preserve"><!-- --></script>
|
||||
</div></body></html>
|
||||
+216
@@ -0,0 +1,216 @@
|
||||
# sax js
|
||||
|
||||
A sax-style parser for XML and HTML.
|
||||
|
||||
Designed with [node](http://nodejs.org/) in mind, but should work fine in
|
||||
the browser or other CommonJS implementations.
|
||||
|
||||
## What This Is
|
||||
|
||||
* A very simple tool to parse through an XML string.
|
||||
* A stepping stone to a streaming HTML parser.
|
||||
* A handy way to deal with RSS and other mostly-ok-but-kinda-broken XML
|
||||
docs.
|
||||
|
||||
## What This Is (probably) Not
|
||||
|
||||
* An HTML Parser - That's a fine goal, but this isn't it. It's just
|
||||
XML.
|
||||
* A DOM Builder - You can use it to build an object model out of XML,
|
||||
but it doesn't do that out of the box.
|
||||
* XSLT - No DOM = no querying.
|
||||
* 100% Compliant with (some other SAX implementation) - Most SAX
|
||||
implementations are in Java and do a lot more than this does.
|
||||
* An XML Validator - It does a little validation when in strict mode, but
|
||||
not much.
|
||||
* A Schema-Aware XSD Thing - Schemas are an exercise in fetishistic
|
||||
masochism.
|
||||
* A DTD-aware Thing - Fetching DTDs is a much bigger job.
|
||||
|
||||
## Regarding `<!DOCTYPE`s and `<!ENTITY`s
|
||||
|
||||
The parser will handle the basic XML entities in text nodes and attribute
|
||||
values: `& < > ' "`. It's possible to define additional
|
||||
entities in XML by putting them in the DTD. This parser doesn't do anything
|
||||
with that. If you want to listen to the `ondoctype` event, and then fetch
|
||||
the doctypes, and read the entities and add them to `parser.ENTITIES`, then
|
||||
be my guest.
|
||||
|
||||
Unknown entities will fail in strict mode, and in loose mode, will pass
|
||||
through unmolested.
|
||||
|
||||
## Usage
|
||||
|
||||
var sax = require("./lib/sax"),
|
||||
strict = true, // set to false for html-mode
|
||||
parser = sax.parser(strict);
|
||||
|
||||
parser.onerror = function (e) {
|
||||
// an error happened.
|
||||
};
|
||||
parser.ontext = function (t) {
|
||||
// got some text. t is the string of text.
|
||||
};
|
||||
parser.onopentag = function (node) {
|
||||
// opened a tag. node has "name" and "attributes"
|
||||
};
|
||||
parser.onattribute = function (attr) {
|
||||
// an attribute. attr has "name" and "value"
|
||||
};
|
||||
parser.onend = function () {
|
||||
// parser stream is done, and ready to have more stuff written to it.
|
||||
};
|
||||
|
||||
parser.write('<xml>Hello, <who name="world">world</who>!</xml>').close();
|
||||
|
||||
// stream usage
|
||||
// takes the same options as the parser
|
||||
var saxStream = require("sax").createStream(strict, options)
|
||||
saxStream.on("error", function (e) {
|
||||
// unhandled errors will throw, since this is a proper node
|
||||
// event emitter.
|
||||
console.error("error!", e)
|
||||
// clear the error
|
||||
this._parser.error = null
|
||||
this._parser.resume()
|
||||
})
|
||||
saxStream.on("opentag", function (node) {
|
||||
// same object as above
|
||||
})
|
||||
// pipe is supported, and it's readable/writable
|
||||
// same chunks coming in also go out.
|
||||
fs.createReadStream("file.xml")
|
||||
.pipe(saxStream)
|
||||
.pipe(fs.createWriteStream("file-copy.xml"))
|
||||
|
||||
|
||||
|
||||
## Arguments
|
||||
|
||||
Pass the following arguments to the parser function. All are optional.
|
||||
|
||||
`strict` - Boolean. Whether or not to be a jerk. Default: `false`.
|
||||
|
||||
`opt` - Object bag of settings regarding string formatting. All default to `false`.
|
||||
|
||||
Settings supported:
|
||||
|
||||
* `trim` - Boolean. Whether or not to trim text and comment nodes.
|
||||
* `normalize` - Boolean. If true, then turn any whitespace into a single
|
||||
space.
|
||||
* `lowercase` - Boolean. If true, then lowercase tag names and attribute names
|
||||
in loose mode, rather than uppercasing them.
|
||||
* `xmlns` - Boolean. If true, then namespaces are supported.
|
||||
* `position` - Boolean. If false, then don't track line/col/position.
|
||||
|
||||
## Methods
|
||||
|
||||
`write` - Write bytes onto the stream. You don't have to do this all at
|
||||
once. You can keep writing as much as you want.
|
||||
|
||||
`close` - Close the stream. Once closed, no more data may be written until
|
||||
it is done processing the buffer, which is signaled by the `end` event.
|
||||
|
||||
`resume` - To gracefully handle errors, assign a listener to the `error`
|
||||
event. Then, when the error is taken care of, you can call `resume` to
|
||||
continue parsing. Otherwise, the parser will not continue while in an error
|
||||
state.
|
||||
|
||||
## Members
|
||||
|
||||
At all times, the parser object will have the following members:
|
||||
|
||||
`line`, `column`, `position` - Indications of the position in the XML
|
||||
document where the parser currently is looking.
|
||||
|
||||
`startTagPosition` - Indicates the position where the current tag starts.
|
||||
|
||||
`closed` - Boolean indicating whether or not the parser can be written to.
|
||||
If it's `true`, then wait for the `ready` event to write again.
|
||||
|
||||
`strict` - Boolean indicating whether or not the parser is a jerk.
|
||||
|
||||
`opt` - Any options passed into the constructor.
|
||||
|
||||
`tag` - The current tag being dealt with.
|
||||
|
||||
And a bunch of other stuff that you probably shouldn't touch.
|
||||
|
||||
## Events
|
||||
|
||||
All events emit with a single argument. To listen to an event, assign a
|
||||
function to `on<eventname>`. Functions get executed in the this-context of
|
||||
the parser object. The list of supported events are also in the exported
|
||||
`EVENTS` array.
|
||||
|
||||
When using the stream interface, assign handlers using the EventEmitter
|
||||
`on` function in the normal fashion.
|
||||
|
||||
`error` - Indication that something bad happened. The error will be hanging
|
||||
out on `parser.error`, and must be deleted before parsing can continue. By
|
||||
listening to this event, you can keep an eye on that kind of stuff. Note:
|
||||
this happens *much* more in strict mode. Argument: instance of `Error`.
|
||||
|
||||
`text` - Text node. Argument: string of text.
|
||||
|
||||
`doctype` - The `<!DOCTYPE` declaration. Argument: doctype string.
|
||||
|
||||
`processinginstruction` - Stuff like `<?xml foo="blerg" ?>`. Argument:
|
||||
object with `name` and `body` members. Attributes are not parsed, as
|
||||
processing instructions have implementation dependent semantics.
|
||||
|
||||
`sgmldeclaration` - Random SGML declarations. Stuff like `<!ENTITY p>`
|
||||
would trigger this kind of event. This is a weird thing to support, so it
|
||||
might go away at some point. SAX isn't intended to be used to parse SGML,
|
||||
after all.
|
||||
|
||||
`opentag` - An opening tag. Argument: object with `name` and `attributes`.
|
||||
In non-strict mode, tag names are uppercased, unless the `lowercase`
|
||||
option is set. If the `xmlns` option is set, then it will contain
|
||||
namespace binding information on the `ns` member, and will have a
|
||||
`local`, `prefix`, and `uri` member.
|
||||
|
||||
`closetag` - A closing tag. In loose mode, tags are auto-closed if their
|
||||
parent closes. In strict mode, well-formedness is enforced. Note that
|
||||
self-closing tags will have `closeTag` emitted immediately after `openTag`.
|
||||
Argument: tag name.
|
||||
|
||||
`attribute` - An attribute node. Argument: object with `name` and `value`.
|
||||
In non-strict mode, attribute names are uppercased, unless the `lowercase`
|
||||
option is set. If the `xmlns` option is set, it will also contains namespace
|
||||
information.
|
||||
|
||||
`comment` - A comment node. Argument: the string of the comment.
|
||||
|
||||
`opencdata` - The opening tag of a `<![CDATA[` block.
|
||||
|
||||
`cdata` - The text of a `<![CDATA[` block. Since `<![CDATA[` blocks can get
|
||||
quite large, this event may fire multiple times for a single block, if it
|
||||
is broken up into multiple `write()`s. Argument: the string of random
|
||||
character data.
|
||||
|
||||
`closecdata` - The closing tag (`]]>`) of a `<![CDATA[` block.
|
||||
|
||||
`opennamespace` - If the `xmlns` option is set, then this event will
|
||||
signal the start of a new namespace binding.
|
||||
|
||||
`closenamespace` - If the `xmlns` option is set, then this event will
|
||||
signal the end of a namespace binding.
|
||||
|
||||
`end` - Indication that the closed stream has ended.
|
||||
|
||||
`ready` - Indication that the stream has reset, and is ready to be written
|
||||
to.
|
||||
|
||||
`noscript` - In non-strict mode, `<script>` tags trigger a `"script"`
|
||||
event, and their contents are not checked for special xml characters.
|
||||
If you pass `noscript: true`, then this behavior is suppressed.
|
||||
|
||||
## Reporting Problems
|
||||
|
||||
It's best to write a failing test if you find an issue. I will always
|
||||
accept pull requests with failing tests if they demonstrate intended
|
||||
behavior, but it is very hard to figure out what issue you're describing
|
||||
without a test. Writing a test is also the best way for you yourself
|
||||
to figure out if you really understand the issue you think you have with
|
||||
sax-js.
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "sax",
|
||||
"description": "An evented streaming XML parser in JavaScript",
|
||||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
||||
"version": "0.5.2",
|
||||
"main": "lib/sax.js",
|
||||
"license": "BSD",
|
||||
"scripts": [
|
||||
"lib/sax.js"
|
||||
],
|
||||
"repository": "git://github.com/isaacs/sax-js.git"
|
||||
}
|
||||
+8002
File diff suppressed because it is too large.
Load diff
+29
@@ -0,0 +1,29 @@
|
||||
|
||||
var fs = require("fs"),
|
||||
util = require("util"),
|
||||
path = require("path"),
|
||||
xml = fs.readFileSync(path.join(__dirname, "test.xml"), "utf8"),
|
||||
sax = require("../lib/sax"),
|
||||
strict = sax.parser(true),
|
||||
loose = sax.parser(false, {trim:true}),
|
||||
inspector = function (ev) { return function (data) {
|
||||
console.error("%s %s %j", this.line+":"+this.column, ev, data);
|
||||
}};
|
||||
|
||||
sax.EVENTS.forEach(function (ev) {
|
||||
loose["on"+ev] = inspector(ev);
|
||||
});
|
||||
loose.onend = function () {
|
||||
console.error("end");
|
||||
console.error(loose);
|
||||
};
|
||||
|
||||
// do this in random bits at a time to verify that it works.
|
||||
(function () {
|
||||
if (xml) {
|
||||
var c = Math.ceil(Math.random() * 1000)
|
||||
loose.write(xml.substr(0,c));
|
||||
xml = xml.substr(c);
|
||||
process.nextTick(arguments.callee);
|
||||
} else loose.close();
|
||||
})();
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
// pull out /GeneralSearchResponse/categories/category/items/product tags
|
||||
// the rest we don't care about.
|
||||
|
||||
var sax = require("../lib/sax.js")
|
||||
var fs = require("fs")
|
||||
var path = require("path")
|
||||
var xmlFile = path.resolve(__dirname, "shopping.xml")
|
||||
var util = require("util")
|
||||
var http = require("http")
|
||||
|
||||
fs.readFile(xmlFile, function (er, d) {
|
||||
http.createServer(function (req, res) {
|
||||
if (er) throw er
|
||||
var xmlstr = d.toString("utf8")
|
||||
|
||||
var parser = sax.parser(true)
|
||||
var products = []
|
||||
var product = null
|
||||
var currentTag = null
|
||||
|
||||
parser.onclosetag = function (tagName) {
|
||||
if (tagName === "product") {
|
||||
products.push(product)
|
||||
currentTag = product = null
|
||||
return
|
||||
}
|
||||
if (currentTag && currentTag.parent) {
|
||||
var p = currentTag.parent
|
||||
delete currentTag.parent
|
||||
currentTag = p
|
||||
}
|
||||
}
|
||||
|
||||
parser.onopentag = function (tag) {
|
||||
if (tag.name !== "product" && !product) return
|
||||
if (tag.name === "product") {
|
||||
product = tag
|
||||
}
|
||||
tag.parent = currentTag
|
||||
tag.children = []
|
||||
tag.parent && tag.parent.children.push(tag)
|
||||
currentTag = tag
|
||||
}
|
||||
|
||||
parser.ontext = function (text) {
|
||||
if (currentTag) currentTag.children.push(text)
|
||||
}
|
||||
|
||||
parser.onend = function () {
|
||||
var out = util.inspect(products, false, 3, true)
|
||||
res.writeHead(200, {"content-type":"application/json"})
|
||||
res.end("{\"ok\":true}")
|
||||
// res.end(JSON.stringify(products))
|
||||
}
|
||||
|
||||
parser.write(xmlstr).end()
|
||||
}).listen(1337)
|
||||
})
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
require("http").createServer(function (req, res) {
|
||||
res.writeHead(200, {"content-type":"application/json"})
|
||||
res.end(JSON.stringify({ok: true}))
|
||||
}).listen(1337)
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<root>
|
||||
something<else> blerm <slurm
|
||||
|
||||
|
||||
attrib =
|
||||
"blorg" ></else><!-- COMMENT!
|
||||
|
||||
--><![CDATA[processing...]]> <selfclosing tag="blr>""/> a bit down here</root>
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
var sax = require("../lib/sax")
|
||||
, printer = sax.createStream(false, {lowercasetags:true, trim:true})
|
||||
, fs = require("fs")
|
||||
|
||||
function entity (str) {
|
||||
return str.replace('"', '"')
|
||||
}
|
||||
|
||||
printer.tabstop = 2
|
||||
printer.level = 0
|
||||
printer.indent = function () {
|
||||
print("\n")
|
||||
for (var i = this.level; i > 0; i --) {
|
||||
for (var j = this.tabstop; j > 0; j --) {
|
||||
print(" ")
|
||||
}
|
||||
}
|
||||
}
|
||||
printer.on("opentag", function (tag) {
|
||||
this.indent()
|
||||
this.level ++
|
||||
print("<"+tag.name)
|
||||
for (var i in tag.attributes) {
|
||||
print(" "+i+"=\""+entity(tag.attributes[i])+"\"")
|
||||
}
|
||||
print(">")
|
||||
})
|
||||
|
||||
printer.on("text", ontext)
|
||||
printer.on("doctype", ontext)
|
||||
function ontext (text) {
|
||||
this.indent()
|
||||
print(text)
|
||||
}
|
||||
|
||||
printer.on("closetag", function (tag) {
|
||||
this.level --
|
||||
this.indent()
|
||||
print("</"+tag+">")
|
||||
})
|
||||
|
||||
printer.on("cdata", function (data) {
|
||||
this.indent()
|
||||
print("<![CDATA["+data+"]]>")
|
||||
})
|
||||
|
||||
printer.on("comment", function (comment) {
|
||||
this.indent()
|
||||
print("<!--"+comment+"-->")
|
||||
})
|
||||
|
||||
printer.on("error", function (error) {
|
||||
console.error(error)
|
||||
throw error
|
||||
})
|
||||
|
||||
if (!process.argv[2]) {
|
||||
throw new Error("Please provide an xml file to prettify\n"+
|
||||
"TODO: read from stdin or take a file")
|
||||
}
|
||||
var xmlfile = require("path").join(process.cwd(), process.argv[2])
|
||||
var fstr = fs.createReadStream(xmlfile, { encoding: "utf8" })
|
||||
|
||||
function print (c) {
|
||||
if (!process.stdout.write(c)) {
|
||||
fstr.pause()
|
||||
}
|
||||
}
|
||||
|
||||
process.stdout.on("drain", function () {
|
||||
fstr.resume()
|
||||
})
|
||||
|
||||
fstr.pipe(printer)
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
|
||||
<GeneralSearchResponse xmlns="urn:types.partner.api.shopping.com"><serverDetail><apiEnv>sandbox</apiEnv><apiVersion>3.1 r31.Kadu4DC.phase3</apiVersion><buildNumber>5778</buildNumber><buildTimestamp>2011.10.06 15:37:23 PST</buildTimestamp><requestId>p2.a121bc2aaf029435dce6</requestId><timestamp>2011-10-21T18:38:45.982-04:00</timestamp><responseTime>P0Y0M0DT0H0M0.169S</responseTime></serverDetail><exceptions exceptionCount="1"><exception type="warning"><code>1112</code><message>You are currently using the SDC API sandbox environment! No clicks to merchant URLs from this response will be paid. Please change the host of your API requests to 'publisher.api.shopping.com' when you have finished development and testing</message></exception></exceptions><clientTracking height="19" type="logo" width="106"><sourceURL>http://statTest.dealtime.com/pixel/noscript?PV_EvnTyp=APPV&APPV_APITSP=10%2F21%2F11_06%3A38%3A45_PM&APPV_DSPRQSID=p2.a121bc2aaf029435dce6&APPV_IMGURL=http://img.shopping.com/sc/glb/sdc_logo_106x19.gif&APPV_LI_LNKINID=7000610&APPV_LI_SBMKYW=nikon&APPV_MTCTYP=1000&APPV_PRTID=2002&APPV_BrnID=14804</sourceURL><hrefURL>http://www.shopping.com/digital-cameras/products</hrefURL><titleText>Digital Cameras</titleText><altText>Digital Cameras</altText></clientTracking><searchHistory><categorySelection id="3"><name>Electronics</name><categoryURL>http://www.shopping.com/xCH-electronics-nikon~linkin_id-7000610?oq=nikon</categoryURL></categorySelection><categorySelection id="449"><name>Cameras and Photography</name><categoryURL>http://www.shopping.com/xCH-cameras_and_photography-nikon~linkin_id-7000610?oq=nikon</categoryURL></categorySelection><categorySelection id="7185"><name>Digital Cameras</name><categoryURL>http://www.shopping.com/digital-cameras/nikon/products?oq=nikon&linkin_id=7000610</categoryURL></categorySelection><dynamicNavigationHistory><keywordSearch dropped="false" modified="false"><originalKeyword>nikon</originalKeyword><resultKeyword>nikon</resultKeyword></keywordSearch></dynamicNavigationHistory></searchHistory><categories matchedCategoryCount="1" returnedCategoryCount="1"><category id="7185"><name>Digital Cameras</name><categoryURL>http://www.shopping.com/digital-cameras/nikon/products?oq=nikon&linkin_id=7000610</categoryURL><items matchedItemCount="322" pageNumber="1" returnedItemCount="5"><product id="101677489"><name>Nikon D3100 Digital Camera</name><shortDescription>14.2 Megapixel, SLR Camera, 3 in. LCD Screen, With High Definition Video, Weight: 1 lb.</shortDescription><fullDescription>The Nikon D3100 digital SLR camera speaks to the growing ranks of enthusiastic D-SLR users and aspiring photographers by providing an easy-to-use and affordable entrance to the world of Nikon D-SLR’s. The 14.2-megapixel D3100 has powerful features, such as the enhanced Guide Mode that makes it easy to unleash creative potential and capture memories with still images and full HD video. Like having a personal photo tutor at your fingertips, this unique feature provides a simple graphical interface on the camera’s LCD that guides users by suggesting and/or adjusting camera settings to achieve the desired end result images. The D3100 is also the world’s first D-SLR to introduce full time auto focus (AF) in Live View and D-Movie mode to effortlessly achieve the critical focus needed when shooting Full HD 1080p video.</fullDescription><images><image available="true" height="100" width="100"><sourceURL>http://di1.shopping.com/images/pi/93/bc/04/101677489-100x100-0-0.jpg?p=p2.a121bc2aaf029435dce6&a=2&c=1&l=7000610&t=111021183845&r=1</sourceURL></image><image available="true" height="200" width="200"><sourceURL>http://di1.shopping.com/images/pi/93/bc/04/101677489-200x200-0-0.jpg?p=p2.a121bc2aaf029435dce6&a=2&c=1&l=7000610&t=111021183845&r=1</sourceURL></image><image available="true" height="300" width="300"><sourceURL>http://di1.shopping.com/images/pi/93/bc/04/101677489-300x300-0-0.jpg?p=p2.a121bc2aaf029435dce6&a=2&c=1&l=7000610&t=111021183845&r=1</sourceURL></image><image available="true" height="400" width="400"><sourceURL>http://di1.shopping.com/images/pi/93/bc/04/101677489-400x400-0-0.jpg?p=p2.a121bc2aaf029435dce6&a=2&c=1&l=7000610&t=111021183845&r=1</sourceURL></image><image available="true" height="500" width="606"><sourceURL>http://di1.shopping.com/images/pi/93/bc/04/101677489-606x500-0-0.jpg?p=p2.a121bc2aaf029435dce6&a=2&c=1&l=7000610&t=111021183845&r=1</sourceURL></image></images><rating><reviewCount>9</reviewCount><rating>4.56</rating><ratingImage height="18" width="91"><sourceURL>http://img.shopping.com/sc/pr/sdc_stars_sm_4.5.gif</sourceURL></ratingImage><reviewURL>http://www.shopping.com/Nikon-D3100/reviews~linkin_id-7000610</reviewURL></rating><minPrice>429.00</minPrice><maxPrice>1360.00</maxPrice><productOffersURL>http://www.shopping.com/Nikon-D3100/prices~linkiLine truncated
|
||||
+870
@@ -0,0 +1,870 @@
|
||||
<!--
|
||||
This is HTML 4.01 Strict DTD, which excludes the presentation
|
||||
attributes and elements that W3C expects to phase out as
|
||||
support for style sheets matures. Authors should use the Strict
|
||||
DTD when possible, but may use the Transitional DTD when support
|
||||
for presentation attribute and elements is required.
|
||||
|
||||
HTML 4 includes mechanisms for style sheets, scripting,
|
||||
embedding objects, improved support for right to left and mixed
|
||||
direction text, and enhancements to forms for improved
|
||||
accessibility for people with disabilities.
|
||||
|
||||
Draft: $Date: 1999/12/24 23:37:48 $
|
||||
|
||||
Authors:
|
||||
Dave Raggett <dsr@w3.org>
|
||||
Arnaud Le Hors <lehors@w3.org>
|
||||
Ian Jacobs <ij@w3.org>
|
||||
|
||||
Further information about HTML 4.01 is available at:
|
||||
|
||||
http://www.w3.org/TR/1999/REC-html401-19991224
|
||||
|
||||
|
||||
The HTML 4.01 specification includes additional
|
||||
syntactic constraints that cannot be expressed within
|
||||
the DTDs.
|
||||
|
||||
-->
|
||||
<!--
|
||||
Typical usage:
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
...
|
||||
</head>
|
||||
<body>
|
||||
...
|
||||
</body>
|
||||
</html>
|
||||
|
||||
The URI used as a system identifier with the public identifier allows
|
||||
the user agent to download the DTD and entity sets as needed.
|
||||
|
||||
The FPI for the Transitional HTML 4.01 DTD is:
|
||||
|
||||
"-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
|
||||
This version of the transitional DTD is:
|
||||
|
||||
http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd
|
||||
|
||||
If you are writing a document that includes frames, use
|
||||
the following FPI:
|
||||
|
||||
"-//W3C//DTD HTML 4.01 Frameset//EN"
|
||||
|
||||
This version of the frameset DTD is:
|
||||
|
||||
http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd
|
||||
|
||||
Use the following (relative) URIs to refer to
|
||||
the DTDs and entity definitions of this specification:
|
||||
|
||||
"strict.dtd"
|
||||
"loose.dtd"
|
||||
"frameset.dtd"
|
||||
"HTMLlat1.ent"
|
||||
"HTMLsymbol.ent"
|
||||
"HTMLspecial.ent"
|
||||
|
||||
-->
|
||||
|
||||
<!--================== Imported Names ====================================-->
|
||||
<!-- Feature Switch for frameset documents -->
|
||||
<!ENTITY % HTML.Frameset "IGNORE">
|
||||
|
||||
<!ENTITY % ContentType "CDATA"
|
||||
-- media type, as per [RFC2045]
|
||||
-->
|
||||
|
||||
<!ENTITY % ContentTypes "CDATA"
|
||||
-- comma-separated list of media types, as per [RFC2045]
|
||||
-->
|
||||
|
||||
<!ENTITY % Charset "CDATA"
|
||||
-- a character encoding, as per [RFC2045]
|
||||
-->
|
||||
|
||||
<!ENTITY % Charsets "CDATA"
|
||||
-- a space-separated list of character encodings, as per [RFC2045]
|
||||
-->
|
||||
|
||||
<!ENTITY % LanguageCode "NAME"
|
||||
-- a language code, as per [RFC1766]
|
||||
-->
|
||||
|
||||
<!ENTITY % Character "CDATA"
|
||||
-- a single character from [ISO10646]
|
||||
-->
|
||||
|
||||
<!ENTITY % LinkTypes "CDATA"
|
||||
-- space-separated list of link types
|
||||
-->
|
||||
|
||||
<!ENTITY % MediaDesc "CDATA"
|
||||
-- single or comma-separated list of media descriptors
|
||||
-->
|
||||
|
||||
<!ENTITY % URI "CDATA"
|
||||
-- a Uniform Resource Identifier,
|
||||
see [URI]
|
||||
-->
|
||||
|
||||
<!ENTITY % Datetime "CDATA" -- date and time information. ISO date format -->
|
||||
|
||||
|
||||
<!ENTITY % Script "CDATA" -- script expression -->
|
||||
|
||||
<!ENTITY % StyleSheet "CDATA" -- style sheet data -->
|
||||
|
||||
|
||||
|
||||
<!ENTITY % Text "CDATA">
|
||||
|
||||
|
||||
<!-- Parameter Entities -->
|
||||
|
||||
<!ENTITY % head.misc "SCRIPT|STYLE|META|LINK|OBJECT" -- repeatable head elements -->
|
||||
|
||||
<!ENTITY % heading "H1|H2|H3|H4|H5|H6">
|
||||
|
||||
<!ENTITY % list "UL | OL">
|
||||
|
||||
<!ENTITY % preformatted "PRE">
|
||||
|
||||
|
||||
<!--================ Character mnemonic entities =========================-->
|
||||
|
||||
<!ENTITY % HTMLlat1 PUBLIC
|
||||
"-//W3C//ENTITIES Latin1//EN//HTML"
|
||||
"HTMLlat1.ent">
|
||||
%HTMLlat1;
|
||||
|
||||
<!ENTITY % HTMLsymbol PUBLIC
|
||||
"-//W3C//ENTITIES Symbols//EN//HTML"
|
||||
"HTMLsymbol.ent">
|
||||
%HTMLsymbol;
|
||||
|
||||
<!ENTITY % HTMLspecial PUBLIC
|
||||
"-//W3C//ENTITIES Special//EN//HTML"
|
||||
"HTMLspecial.ent">
|
||||
%HTMLspecial;
|
||||
<!--=================== Generic Attributes ===============================-->
|
||||
|
||||
<!ENTITY % coreattrs
|
||||
"id ID #IMPLIED -- document-wide unique id --
|
||||
class CDATA #IMPLIED -- space-separated list of classes --
|
||||
style %StyleSheet; #IMPLIED -- associated style info --
|
||||
title %Text; #IMPLIED -- advisory title --"
|
||||
>
|
||||
|
||||
<!ENTITY % i18n
|
||||
"lang %LanguageCode; #IMPLIED -- language code --
|
||||
dir (ltr|rtl) #IMPLIED -- direction for weak/neutral text --"
|
||||
>
|
||||
|
||||
<!ENTITY % events
|
||||
"onclick %Script; #IMPLIED -- a pointer button was clicked --
|
||||
ondblclick %Script; #IMPLIED -- a pointer button was double clicked--
|
||||
onmousedown %Script; #IMPLIED -- a pointer button was pressed down --
|
||||
onmouseup %Script; #IMPLIED -- a pointer button was released --
|
||||
onmouseover %Script; #IMPLIED -- a pointer was moved onto --
|
||||
onmousemove %Script; #IMPLIED -- a pointer was moved within --
|
||||
onmouseout %Script; #IMPLIED -- a pointer was moved away --
|
||||
onkeypress %Script; #IMPLIED -- a key was pressed and released --
|
||||
onkeydown %Script; #IMPLIED -- a key was pressed down --
|
||||
onkeyup %Script; #IMPLIED -- a key was released --"
|
||||
>
|
||||
|
||||
<!-- Reserved Feature Switch -->
|
||||
<!ENTITY % HTML.Reserved "IGNORE">
|
||||
|
||||
<!-- The following attributes are reserved for possible future use -->
|
||||
<![ %HTML.Reserved; [
|
||||
<!ENTITY % reserved
|
||||
"datasrc %URI; #IMPLIED -- a single or tabular Data Source --
|
||||
datafld CDATA #IMPLIED -- the property or column name --
|
||||
dataformatas (plaintext|html) plaintext -- text or html --"
|
||||
>
|
||||
]]>
|
||||
|
||||
<!ENTITY % reserved "">
|
||||
|
||||
<!ENTITY % attrs "%coreattrs; %i18n; %events;">
|
||||
|
||||
|
||||
<!--=================== Text Markup ======================================-->
|
||||
|
||||
<!ENTITY % fontstyle
|
||||
"TT | I | B | BIG | SMALL">
|
||||
|
||||
<!ENTITY % phrase "EM | STRONG | DFN | CODE |
|
||||
SAMP | KBD | VAR | CITE | ABBR | ACRONYM" >
|
||||
|
||||
<!ENTITY % special
|
||||
"A | IMG | OBJECT | BR | SCRIPT | MAP | Q | SUB | SUP | SPAN | BDO">
|
||||
|
||||
<!ENTITY % formctrl "INPUT | SELECT | TEXTAREA | LABEL | BUTTON">
|
||||
|
||||
<!-- %inline; covers inline or "text-level" elements -->
|
||||
<!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; | %formctrl;">
|
||||
|
||||
<!ELEMENT (%fontstyle;|%phrase;) - - (%inline;)*>
|
||||
<!ATTLIST (%fontstyle;|%phrase;)
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!ELEMENT (SUB|SUP) - - (%inline;)* -- subscript, superscript -->
|
||||
<!ATTLIST (SUB|SUP)
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!ELEMENT SPAN - - (%inline;)* -- generic language/style container -->
|
||||
<!ATTLIST SPAN
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
%reserved; -- reserved for possible future use --
|
||||
>
|
||||
|
||||
<!ELEMENT BDO - - (%inline;)* -- I18N BiDi over-ride -->
|
||||
<!ATTLIST BDO
|
||||
%coreattrs; -- id, class, style, title --
|
||||
lang %LanguageCode; #IMPLIED -- language code --
|
||||
dir (ltr|rtl) #REQUIRED -- directionality --
|
||||
>
|
||||
|
||||
|
||||
<!ELEMENT BR - O EMPTY -- forced line break -->
|
||||
<!ATTLIST BR
|
||||
%coreattrs; -- id, class, style, title --
|
||||
>
|
||||
|
||||
<!--================== HTML content models ===============================-->
|
||||
|
||||
<!--
|
||||
HTML has two basic content models:
|
||||
|
||||
%inline; character level elements and text strings
|
||||
%block; block-like elements e.g. paragraphs and lists
|
||||
-->
|
||||
|
||||
<!ENTITY % block
|
||||
"P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
|
||||
BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">
|
||||
|
||||
<!ENTITY % flow "%block; | %inline;">
|
||||
|
||||
<!--=================== Document Body ====================================-->
|
||||
|
||||
<!ELEMENT BODY O O (%block;|SCRIPT)+ +(INS|DEL) -- document body -->
|
||||
<!ATTLIST BODY
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
onload %Script; #IMPLIED -- the document has been loaded --
|
||||
onunload %Script; #IMPLIED -- the document has been removed --
|
||||
>
|
||||
|
||||
<!ELEMENT ADDRESS - - (%inline;)* -- information on author -->
|
||||
<!ATTLIST ADDRESS
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!ELEMENT DIV - - (%flow;)* -- generic language/style container -->
|
||||
<!ATTLIST DIV
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
%reserved; -- reserved for possible future use --
|
||||
>
|
||||
|
||||
|
||||
<!--================== The Anchor Element ================================-->
|
||||
|
||||
<!ENTITY % Shape "(rect|circle|poly|default)">
|
||||
<!ENTITY % Coords "CDATA" -- comma-separated list of lengths -->
|
||||
|
||||
<!ELEMENT A - - (%inline;)* -(A) -- anchor -->
|
||||
<!ATTLIST A
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
charset %Charset; #IMPLIED -- char encoding of linked resource --
|
||||
type %ContentType; #IMPLIED -- advisory content type --
|
||||
name CDATA #IMPLIED -- named link end --
|
||||
href %URI; #IMPLIED -- URI for linked resource --
|
||||
hreflang %LanguageCode; #IMPLIED -- language code --
|
||||
rel %LinkTypes; #IMPLIED -- forward link types --
|
||||
rev %LinkTypes; #IMPLIED -- reverse link types --
|
||||
accesskey %Character; #IMPLIED -- accessibility key character --
|
||||
shape %Shape; rect -- for use with client-side image maps --
|
||||
coords %Coords; #IMPLIED -- for use with client-side image maps --
|
||||
tabindex NUMBER #IMPLIED -- position in tabbing order --
|
||||
onfocus %Script; #IMPLIED -- the element got the focus --
|
||||
onblur %Script; #IMPLIED -- the element lost the focus --
|
||||
>
|
||||
|
||||
<!--================== Client-side image maps ============================-->
|
||||
|
||||
<!-- These can be placed in the same document or grouped in a
|
||||
separate document although this isn't yet widely supported -->
|
||||
|
||||
<!ELEMENT MAP - - ((%block;) | AREA)+ -- client-side image map -->
|
||||
<!ATTLIST MAP
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
name CDATA #REQUIRED -- for reference by usemap --
|
||||
>
|
||||
|
||||
<!ELEMENT AREA - O EMPTY -- client-side image map area -->
|
||||
<!ATTLIST AREA
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
shape %Shape; rect -- controls interpretation of coords --
|
||||
coords %Coords; #IMPLIED -- comma-separated list of lengths --
|
||||
href %URI; #IMPLIED -- URI for linked resource --
|
||||
nohref (nohref) #IMPLIED -- this region has no action --
|
||||
alt %Text; #REQUIRED -- short description --
|
||||
tabindex NUMBER #IMPLIED -- position in tabbing order --
|
||||
accesskey %Character; #IMPLIED -- accessibility key character --
|
||||
onfocus %Script; #IMPLIED -- the element got the focus --
|
||||
onblur %Script; #IMPLIED -- the element lost the focus --
|
||||
>
|
||||
|
||||
<!--================== The LINK Element ==================================-->
|
||||
|
||||
<!--
|
||||
Relationship values can be used in principle:
|
||||
|
||||
a) for document specific toolbars/menus when used
|
||||
with the LINK element in document head e.g.
|
||||
start, contents, previous, next, index, end, help
|
||||
b) to link to a separate style sheet (rel=stylesheet)
|
||||
c) to make a link to a script (rel=script)
|
||||
d) by stylesheets to control how collections of
|
||||
html nodes are rendered into printed documents
|
||||
e) to make a link to a printable version of this document
|
||||
e.g. a postscript or pdf version (rel=alternate media=print)
|
||||
-->
|
||||
|
||||
<!ELEMENT LINK - O EMPTY -- a media-independent link -->
|
||||
<!ATTLIST LINK
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
charset %Charset; #IMPLIED -- char encoding of linked resource --
|
||||
href %URI; #IMPLIED -- URI for linked resource --
|
||||
hreflang %LanguageCode; #IMPLIED -- language code --
|
||||
type %ContentType; #IMPLIED -- advisory content type --
|
||||
rel %LinkTypes; #IMPLIED -- forward link types --
|
||||
rev %LinkTypes; #IMPLIED -- reverse link types --
|
||||
media %MediaDesc; #IMPLIED -- for rendering on these media --
|
||||
>
|
||||
|
||||
<!--=================== Images ===========================================-->
|
||||
|
||||
<!-- Length defined in strict DTD for cellpadding/cellspacing -->
|
||||
<!ENTITY % Length "CDATA" -- nn for pixels or nn% for percentage length -->
|
||||
<!ENTITY % MultiLength "CDATA" -- pixel, percentage, or relative -->
|
||||
|
||||
<![ %HTML.Frameset; [
|
||||
<!ENTITY % MultiLengths "CDATA" -- comma-separated list of MultiLength -->
|
||||
]]>
|
||||
|
||||
<!ENTITY % Pixels "CDATA" -- integer representing length in pixels -->
|
||||
|
||||
|
||||
<!-- To avoid problems with text-only UAs as well as
|
||||
to make image content understandable and navigable
|
||||
to users of non-visual UAs, you need to provide
|
||||
a description with ALT, and avoid server-side image maps -->
|
||||
<!ELEMENT IMG - O EMPTY -- Embedded image -->
|
||||
<!ATTLIST IMG
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
src %URI; #REQUIRED -- URI of image to embed --
|
||||
alt %Text; #REQUIRED -- short description --
|
||||
longdesc %URI; #IMPLIED -- link to long description
|
||||
(complements alt) --
|
||||
name CDATA #IMPLIED -- name of image for scripting --
|
||||
height %Length; #IMPLIED -- override height --
|
||||
width %Length; #IMPLIED -- override width --
|
||||
usemap %URI; #IMPLIED -- use client-side image map --
|
||||
ismap (ismap) #IMPLIED -- use server-side image map --
|
||||
>
|
||||
|
||||
<!-- USEMAP points to a MAP element which may be in this document
|
||||
or an external document, although the latter is not widely supported -->
|
||||
|
||||
<!--==================== OBJECT ======================================-->
|
||||
<!--
|
||||
OBJECT is used to embed objects as part of HTML pages
|
||||
PARAM elements should precede other content. SGML mixed content
|
||||
model technicality precludes specifying this formally ...
|
||||
-->
|
||||
|
||||
<!ELEMENT OBJECT - - (PARAM | %flow;)*
|
||||
-- generic embedded object -->
|
||||
<!ATTLIST OBJECT
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
declare (declare) #IMPLIED -- declare but don't instantiate flag --
|
||||
classid %URI; #IMPLIED -- identifies an implementation --
|
||||
codebase %URI; #IMPLIED -- base URI for classid, data, archive--
|
||||
data %URI; #IMPLIED -- reference to object's data --
|
||||
type %ContentType; #IMPLIED -- content type for data --
|
||||
codetype %ContentType; #IMPLIED -- content type for code --
|
||||
archive CDATA #IMPLIED -- space-separated list of URIs --
|
||||
standby %Text; #IMPLIED -- message to show while loading --
|
||||
height %Length; #IMPLIED -- override height --
|
||||
width %Length; #IMPLIED -- override width --
|
||||
usemap %URI; #IMPLIED -- use client-side image map --
|
||||
name CDATA #IMPLIED -- submit as part of form --
|
||||
tabindex NUMBER #IMPLIED -- position in tabbing order --
|
||||
%reserved; -- reserved for possible future use --
|
||||
>
|
||||
|
||||
<!ELEMENT PARAM - O EMPTY -- named property value -->
|
||||
<!ATTLIST PARAM
|
||||
id ID #IMPLIED -- document-wide unique id --
|
||||
name CDATA #REQUIRED -- property name --
|
||||
value CDATA #IMPLIED -- property value --
|
||||
valuetype (DATA|REF|OBJECT) DATA -- How to interpret value --
|
||||
type %ContentType; #IMPLIED -- content type for value
|
||||
when valuetype=ref --
|
||||
>
|
||||
|
||||
|
||||
<!--=================== Horizontal Rule ==================================-->
|
||||
|
||||
<!ELEMENT HR - O EMPTY -- horizontal rule -->
|
||||
<!ATTLIST HR
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!--=================== Paragraphs =======================================-->
|
||||
|
||||
<!ELEMENT P - O (%inline;)* -- paragraph -->
|
||||
<!ATTLIST P
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!--=================== Headings =========================================-->
|
||||
|
||||
<!--
|
||||
There are six levels of headings from H1 (the most important)
|
||||
to H6 (the least important).
|
||||
-->
|
||||
|
||||
<!ELEMENT (%heading;) - - (%inline;)* -- heading -->
|
||||
<!ATTLIST (%heading;)
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!--=================== Preformatted Text ================================-->
|
||||
|
||||
<!-- excludes markup for images and changes in font size -->
|
||||
<!ENTITY % pre.exclusion "IMG|OBJECT|BIG|SMALL|SUB|SUP">
|
||||
|
||||
<!ELEMENT PRE - - (%inline;)* -(%pre.exclusion;) -- preformatted text -->
|
||||
<!ATTLIST PRE
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!--===================== Inline Quotes ==================================-->
|
||||
|
||||
<!ELEMENT Q - - (%inline;)* -- short inline quotation -->
|
||||
<!ATTLIST Q
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
cite %URI; #IMPLIED -- URI for source document or msg --
|
||||
>
|
||||
|
||||
<!--=================== Block-like Quotes ================================-->
|
||||
|
||||
<!ELEMENT BLOCKQUOTE - - (%block;|SCRIPT)+ -- long quotation -->
|
||||
<!ATTLIST BLOCKQUOTE
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
cite %URI; #IMPLIED -- URI for source document or msg --
|
||||
>
|
||||
|
||||
<!--=================== Inserted/Deleted Text ============================-->
|
||||
|
||||
|
||||
<!-- INS/DEL are handled by inclusion on BODY -->
|
||||
<!ELEMENT (INS|DEL) - - (%flow;)* -- inserted text, deleted text -->
|
||||
<!ATTLIST (INS|DEL)
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
cite %URI; #IMPLIED -- info on reason for change --
|
||||
datetime %Datetime; #IMPLIED -- date and time of change --
|
||||
>
|
||||
|
||||
<!--=================== Lists ============================================-->
|
||||
|
||||
<!-- definition lists - DT for term, DD for its definition -->
|
||||
|
||||
<!ELEMENT DL - - (DT|DD)+ -- definition list -->
|
||||
<!ATTLIST DL
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!ELEMENT DT - O (%inline;)* -- definition term -->
|
||||
<!ELEMENT DD - O (%flow;)* -- definition description -->
|
||||
<!ATTLIST (DT|DD)
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
|
||||
<!ELEMENT OL - - (LI)+ -- ordered list -->
|
||||
<!ATTLIST OL
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!-- Unordered Lists (UL) bullet styles -->
|
||||
<!ELEMENT UL - - (LI)+ -- unordered list -->
|
||||
<!ATTLIST UL
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
|
||||
|
||||
<!ELEMENT LI - O (%flow;)* -- list item -->
|
||||
<!ATTLIST LI
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!--================ Forms ===============================================-->
|
||||
<!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) -- interactive form -->
|
||||
<!ATTLIST FORM
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
action %URI; #REQUIRED -- server-side form handler --
|
||||
method (GET|POST) GET -- HTTP method used to submit the form--
|
||||
enctype %ContentType; "application/x-www-form-urlencoded"
|
||||
accept %ContentTypes; #IMPLIED -- list of MIME types for file upload --
|
||||
name CDATA #IMPLIED -- name of form for scripting --
|
||||
onsubmit %Script; #IMPLIED -- the form was submitted --
|
||||
onreset %Script; #IMPLIED -- the form was reset --
|
||||
accept-charset %Charsets; #IMPLIED -- list of supported charsets --
|
||||
>
|
||||
|
||||
<!-- Each label must not contain more than ONE field -->
|
||||
<!ELEMENT LABEL - - (%inline;)* -(LABEL) -- form field label text -->
|
||||
<!ATTLIST LABEL
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
for IDREF #IMPLIED -- matches field ID value --
|
||||
accesskey %Character; #IMPLIED -- accessibility key character --
|
||||
onfocus %Script; #IMPLIED -- the element got the focus --
|
||||
onblur %Script; #IMPLIED -- the element lost the focus --
|
||||
>
|
||||
|
||||
<!ENTITY % InputType
|
||||
"(TEXT | PASSWORD | CHECKBOX |
|
||||
RADIO | SUBMIT | RESET |
|
||||
FILE | HIDDEN | IMAGE | BUTTON)"
|
||||
>
|
||||
|
||||
<!-- attribute name required for all but submit and reset -->
|
||||
<!ELEMENT INPUT - O EMPTY -- form control -->
|
||||
<!ATTLIST INPUT
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
type %InputType; TEXT -- what kind of widget is needed --
|
||||
name CDATA #IMPLIED -- submit as part of form --
|
||||
value CDATA #IMPLIED -- Specify for radio buttons and checkboxes --
|
||||
checked (checked) #IMPLIED -- for radio buttons and check boxes --
|
||||
disabled (disabled) #IMPLIED -- unavailable in this context --
|
||||
readonly (readonly) #IMPLIED -- for text and passwd --
|
||||
size CDATA #IMPLIED -- specific to each type of field --
|
||||
maxlength NUMBER #IMPLIED -- max chars for text fields --
|
||||
src %URI; #IMPLIED -- for fields with images --
|
||||
alt CDATA #IMPLIED -- short description --
|
||||
usemap %URI; #IMPLIED -- use client-side image map --
|
||||
ismap (ismap) #IMPLIED -- use server-side image map --
|
||||
tabindex NUMBER #IMPLIED -- position in tabbing order --
|
||||
accesskey %Character; #IMPLIED -- accessibility key character --
|
||||
onfocus %Script; #IMPLIED -- the element got the focus --
|
||||
onblur %Script; #IMPLIED -- the element lost the focus --
|
||||
onselect %Script; #IMPLIED -- some text was selected --
|
||||
onchange %Script; #IMPLIED -- the element value was changed --
|
||||
accept %ContentTypes; #IMPLIED -- list of MIME types for file upload --
|
||||
%reserved; -- reserved for possible future use --
|
||||
>
|
||||
|
||||
<!ELEMENT SELECT - - (OPTGROUP|OPTION)+ -- option selector -->
|
||||
<!ATTLIST SELECT
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
name CDATA #IMPLIED -- field name --
|
||||
size NUMBER #IMPLIED -- rows visible --
|
||||
multiple (multiple) #IMPLIED -- default is single selection --
|
||||
disabled (disabled) #IMPLIED -- unavailable in this context --
|
||||
tabindex NUMBER #IMPLIED -- position in tabbing order --
|
||||
onfocus %Script; #IMPLIED -- the element got the focus --
|
||||
onblur %Script; #IMPLIED -- the element lost the focus --
|
||||
onchange %Script; #IMPLIED -- the element value was changed --
|
||||
%reserved; -- reserved for possible future use --
|
||||
>
|
||||
|
||||
<!ELEMENT OPTGROUP - - (OPTION)+ -- option group -->
|
||||
<!ATTLIST OPTGROUP
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
disabled (disabled) #IMPLIED -- unavailable in this context --
|
||||
label %Text; #REQUIRED -- for use in hierarchical menus --
|
||||
>
|
||||
|
||||
<!ELEMENT OPTION - O (#PCDATA) -- selectable choice -->
|
||||
<!ATTLIST OPTION
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
selected (selected) #IMPLIED
|
||||
disabled (disabled) #IMPLIED -- unavailable in this context --
|
||||
label %Text; #IMPLIED -- for use in hierarchical menus --
|
||||
value CDATA #IMPLIED -- defaults to element content --
|
||||
>
|
||||
|
||||
<!ELEMENT TEXTAREA - - (#PCDATA) -- multi-line text field -->
|
||||
<!ATTLIST TEXTAREA
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
name CDATA #IMPLIED
|
||||
rows NUMBER #REQUIRED
|
||||
cols NUMBER #REQUIRED
|
||||
disabled (disabled) #IMPLIED -- unavailable in this context --
|
||||
readonly (readonly) #IMPLIED
|
||||
tabindex NUMBER #IMPLIED -- position in tabbing order --
|
||||
accesskey %Character; #IMPLIED -- accessibility key character --
|
||||
onfocus %Script; #IMPLIED -- the element got the focus --
|
||||
onblur %Script; #IMPLIED -- the element lost the focus --
|
||||
onselect %Script; #IMPLIED -- some text was selected --
|
||||
onchange %Script; #IMPLIED -- the element value was changed --
|
||||
%reserved; -- reserved for possible future use --
|
||||
>
|
||||
|
||||
<!--
|
||||
#PCDATA is to solve the mixed content problem,
|
||||
per specification only whitespace is allowed there!
|
||||
-->
|
||||
<!ELEMENT FIELDSET - - (#PCDATA,LEGEND,(%flow;)*) -- form control group -->
|
||||
<!ATTLIST FIELDSET
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!ELEMENT LEGEND - - (%inline;)* -- fieldset legend -->
|
||||
|
||||
<!ATTLIST LEGEND
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
accesskey %Character; #IMPLIED -- accessibility key character --
|
||||
>
|
||||
|
||||
<!ELEMENT BUTTON - -
|
||||
(%flow;)* -(A|%formctrl;|FORM|FIELDSET)
|
||||
-- push button -->
|
||||
<!ATTLIST BUTTON
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
name CDATA #IMPLIED
|
||||
value CDATA #IMPLIED -- sent to server when submitted --
|
||||
type (button|submit|reset) submit -- for use as form button --
|
||||
disabled (disabled) #IMPLIED -- unavailable in this context --
|
||||
tabindex NUMBER #IMPLIED -- position in tabbing order --
|
||||
accesskey %Character; #IMPLIED -- accessibility key character --
|
||||
onfocus %Script; #IMPLIED -- the element got the focus --
|
||||
onblur %Script; #IMPLIED -- the element lost the focus --
|
||||
%reserved; -- reserved for possible future use --
|
||||
>
|
||||
|
||||
<!--======================= Tables =======================================-->
|
||||
|
||||
<!-- IETF HTML table standard, see [RFC1942] -->
|
||||
|
||||
<!--
|
||||
The BORDER attribute sets the thickness of the frame around the
|
||||
table. The default units are screen pixels.
|
||||
|
||||
The FRAME attribute specifies which parts of the frame around
|
||||
the table should be rendered. The values are not the same as
|
||||
CALS to avoid a name clash with the VALIGN attribute.
|
||||
|
||||
The value "border" is included for backwards compatibility with
|
||||
<TABLE BORDER> which yields frame=border and border=implied
|
||||
For <TABLE BORDER=1> you get border=1 and frame=implied. In this
|
||||
case, it is appropriate to treat this as frame=border for backwards
|
||||
compatibility with deployed browsers.
|
||||
-->
|
||||
<!ENTITY % TFrame "(void|above|below|hsides|lhs|rhs|vsides|box|border)">
|
||||
|
||||
<!--
|
||||
The RULES attribute defines which rules to draw between cells:
|
||||
|
||||
If RULES is absent then assume:
|
||||
"none" if BORDER is absent or BORDER=0 otherwise "all"
|
||||
-->
|
||||
|
||||
<!ENTITY % TRules "(none | groups | rows | cols | all)">
|
||||
|
||||
<!-- horizontal placement of table relative to document -->
|
||||
<!ENTITY % TAlign "(left|center|right)">
|
||||
|
||||
<!-- horizontal alignment attributes for cell contents -->
|
||||
<!ENTITY % cellhalign
|
||||
"align (left|center|right|justify|char) #IMPLIED
|
||||
char %Character; #IMPLIED -- alignment char, e.g. char=':' --
|
||||
charoff %Length; #IMPLIED -- offset for alignment char --"
|
||||
>
|
||||
|
||||
<!-- vertical alignment attributes for cell contents -->
|
||||
<!ENTITY % cellvalign
|
||||
"valign (top|middle|bottom|baseline) #IMPLIED"
|
||||
>
|
||||
|
||||
<!ELEMENT TABLE - -
|
||||
(CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)>
|
||||
<!ELEMENT CAPTION - - (%inline;)* -- table caption -->
|
||||
<!ELEMENT THEAD - O (TR)+ -- table header -->
|
||||
<!ELEMENT TFOOT - O (TR)+ -- table footer -->
|
||||
<!ELEMENT TBODY O O (TR)+ -- table body -->
|
||||
<!ELEMENT COLGROUP - O (COL)* -- table column group -->
|
||||
<!ELEMENT COL - O EMPTY -- table column -->
|
||||
<!ELEMENT TR - O (TH|TD)+ -- table row -->
|
||||
<!ELEMENT (TH|TD) - O (%flow;)* -- table header cell, table data cell-->
|
||||
|
||||
<!ATTLIST TABLE -- table element --
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
summary %Text; #IMPLIED -- purpose/structure for speech output--
|
||||
width %Length; #IMPLIED -- table width --
|
||||
border %Pixels; #IMPLIED -- controls frame width around table --
|
||||
frame %TFrame; #IMPLIED -- which parts of frame to render --
|
||||
rules %TRules; #IMPLIED -- rulings between rows and cols --
|
||||
cellspacing %Length; #IMPLIED -- spacing between cells --
|
||||
cellpadding %Length; #IMPLIED -- spacing within cells --
|
||||
%reserved; -- reserved for possible future use --
|
||||
datapagesize CDATA #IMPLIED -- reserved for possible future use --
|
||||
>
|
||||
|
||||
|
||||
<!ATTLIST CAPTION
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!--
|
||||
COLGROUP groups a set of COL elements. It allows you to group
|
||||
several semantically related columns together.
|
||||
-->
|
||||
<!ATTLIST COLGROUP
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
span NUMBER 1 -- default number of columns in group --
|
||||
width %MultiLength; #IMPLIED -- default width for enclosed COLs --
|
||||
%cellhalign; -- horizontal alignment in cells --
|
||||
%cellvalign; -- vertical alignment in cells --
|
||||
>
|
||||
|
||||
<!--
|
||||
COL elements define the alignment properties for cells in
|
||||
one or more columns.
|
||||
|
||||
The WIDTH attribute specifies the width of the columns, e.g.
|
||||
|
||||
width=64 width in screen pixels
|
||||
width=0.5* relative width of 0.5
|
||||
|
||||
The SPAN attribute causes the attributes of one
|
||||
COL element to apply to more than one column.
|
||||
-->
|
||||
<!ATTLIST COL -- column groups and properties --
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
span NUMBER 1 -- COL attributes affect N columns --
|
||||
width %MultiLength; #IMPLIED -- column width specification --
|
||||
%cellhalign; -- horizontal alignment in cells --
|
||||
%cellvalign; -- vertical alignment in cells --
|
||||
>
|
||||
|
||||
<!--
|
||||
Use THEAD to duplicate headers when breaking table
|
||||
across page boundaries, or for static headers when
|
||||
TBODY sections are rendered in scrolling panel.
|
||||
|
||||
Use TFOOT to duplicate footers when breaking table
|
||||
across page boundaries, or for static footers when
|
||||
TBODY sections are rendered in scrolling panel.
|
||||
|
||||
Use multiple TBODY sections when rules are needed
|
||||
between groups of table rows.
|
||||
-->
|
||||
<!ATTLIST (THEAD|TBODY|TFOOT) -- table section --
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
%cellhalign; -- horizontal alignment in cells --
|
||||
%cellvalign; -- vertical alignment in cells --
|
||||
>
|
||||
|
||||
<!ATTLIST TR -- table row --
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
%cellhalign; -- horizontal alignment in cells --
|
||||
%cellvalign; -- vertical alignment in cells --
|
||||
>
|
||||
|
||||
|
||||
<!-- Scope is simpler than headers attribute for common tables -->
|
||||
<!ENTITY % Scope "(row|col|rowgroup|colgroup)">
|
||||
|
||||
<!-- TH is for headers, TD for data, but for cells acting as both use TD -->
|
||||
<!ATTLIST (TH|TD) -- header or data cell --
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
abbr %Text; #IMPLIED -- abbreviation for header cell --
|
||||
axis CDATA #IMPLIED -- comma-separated list of related headers--
|
||||
headers IDREFS #IMPLIED -- list of id's for header cells --
|
||||
scope %Scope; #IMPLIED -- scope covered by header cells --
|
||||
rowspan NUMBER 1 -- number of rows spanned by cell --
|
||||
colspan NUMBER 1 -- number of cols spanned by cell --
|
||||
%cellhalign; -- horizontal alignment in cells --
|
||||
%cellvalign; -- vertical alignment in cells --
|
||||
>
|
||||
|
||||
|
||||
<!--================ Document Head =======================================-->
|
||||
<!-- %head.misc; defined earlier on as "SCRIPT|STYLE|META|LINK|OBJECT" -->
|
||||
<!ENTITY % head.content "TITLE & BASE?">
|
||||
|
||||
<!ELEMENT HEAD O O (%head.content;) +(%head.misc;) -- document head -->
|
||||
<!ATTLIST HEAD
|
||||
%i18n; -- lang, dir --
|
||||
profile %URI; #IMPLIED -- named dictionary of meta info --
|
||||
>
|
||||
|
||||
<!-- The TITLE element is not considered part of the flow of text.
|
||||
It should be displayed, for example as the page header or
|
||||
window title. Exactly one title is required per document.
|
||||
-->
|
||||
<!ELEMENT TITLE - - (#PCDATA) -(%head.misc;) -- document title -->
|
||||
<!ATTLIST TITLE %i18n>
|
||||
|
||||
|
||||
<!ELEMENT BASE - O EMPTY -- document base URI -->
|
||||
<!ATTLIST BASE
|
||||
href %URI; #REQUIRED -- URI that acts as base URI --
|
||||
>
|
||||
|
||||
<!ELEMENT META - O EMPTY -- generic metainformation -->
|
||||
<!ATTLIST META
|
||||
%i18n; -- lang, dir, for use with content --
|
||||
http-equiv NAME #IMPLIED -- HTTP response header name --
|
||||
name NAME #IMPLIED -- metainformation name --
|
||||
content CDATA #REQUIRED -- associated information --
|
||||
scheme CDATA #IMPLIED -- select form of content --
|
||||
>
|
||||
|
||||
<!ELEMENT STYLE - - %StyleSheet -- style info -->
|
||||
<!ATTLIST STYLE
|
||||
%i18n; -- lang, dir, for use with title --
|
||||
type %ContentType; #REQUIRED -- content type of style language --
|
||||
media %MediaDesc; #IMPLIED -- designed for use with these media --
|
||||
title %Text; #IMPLIED -- advisory title --
|
||||
>
|
||||
|
||||
<!ELEMENT SCRIPT - - %Script; -- script statements -->
|
||||
<!ATTLIST SCRIPT
|
||||
charset %Charset; #IMPLIED -- char encoding of linked resource --
|
||||
type %ContentType; #REQUIRED -- content type of script language --
|
||||
src %URI; #IMPLIED -- URI for an external script --
|
||||
defer (defer) #IMPLIED -- UA may defer execution of script --
|
||||
event CDATA #IMPLIED -- reserved for possible future use --
|
||||
for %URI; #IMPLIED -- reserved for possible future use --
|
||||
>
|
||||
|
||||
<!ELEMENT NOSCRIPT - - (%block;)+
|
||||
-- alternate content container for non script-based rendering -->
|
||||
<!ATTLIST NOSCRIPT
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!--================ Document Structure ==================================-->
|
||||
<!ENTITY % html.content "HEAD, BODY">
|
||||
|
||||
<!ELEMENT HTML O O (%html.content;) -- document root element -->
|
||||
<!ATTLIST HTML
|
||||
%i18n; -- lang, dir --
|
||||
>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<!doctype html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>testing the parser</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>hello
|
||||
|
||||
<script>
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+1254
File diff suppressed because it is too large.
Load diff
+1355
File diff suppressed because it is too large.
Load diff
+108
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"sax@0.5.x",
|
||||
"c:\\users\\luis\\source\\repos\\AACharly\\node_modules\\xml2js"
|
||||
]
|
||||
],
|
||||
"_from": "sax@>=0.5.0-0 <0.6.0-0",
|
||||
"_id": "sax@0.5.8",
|
||||
"_inCache": true,
|
||||
"_location": "/sax",
|
||||
"_npmUser": {
|
||||
"email": "i@izs.me",
|
||||
"name": "isaacs"
|
||||
},
|
||||
"_npmVersion": "1.3.15",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "sax",
|
||||
"raw": "sax@0.5.x",
|
||||
"rawSpec": "0.5.x",
|
||||
"scope": null,
|
||||
"spec": ">=0.5.0-0 <0.6.0-0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/xml2js"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/sax/-/sax-0.5.8.tgz",
|
||||
"_shasum": "d472db228eb331c2506b0e8c15524adb939d12c1",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "sax@0.5.x",
|
||||
"_where": "c:\\users\\luis\\source\\repos\\AACharly\\node_modules\\xml2js",
|
||||
"author": {
|
||||
"email": "i@izs.me",
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"url": "http://blog.izs.me/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/sax-js/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me"
|
||||
},
|
||||
{
|
||||
"name": "Stein Martin Hustad",
|
||||
"email": "stein@hustad.com"
|
||||
},
|
||||
{
|
||||
"name": "Mikeal Rogers",
|
||||
"email": "mikeal.rogers@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Laurie Harper",
|
||||
"email": "laurie@holoweb.net"
|
||||
},
|
||||
{
|
||||
"name": "Jann Horn",
|
||||
"email": "jann@Jann-PC.fritz.box"
|
||||
},
|
||||
{
|
||||
"name": "Elijah Insua",
|
||||
"email": "tmpvar@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Henry Rawas",
|
||||
"email": "henryr@schakra.com"
|
||||
},
|
||||
{
|
||||
"name": "Justin Makeig",
|
||||
"email": "jmpublic@makeig.com"
|
||||
},
|
||||
{
|
||||
"name": "Mike Schilling",
|
||||
"email": "mike@emotive.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"description": "An evented streaming XML parser in JavaScript",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "d472db228eb331c2506b0e8c15524adb939d12c1",
|
||||
"tarball": "https://registry.npmjs.org/sax/-/sax-0.5.8.tgz"
|
||||
},
|
||||
"homepage": "https://github.com/isaacs/sax-js",
|
||||
"installable": true,
|
||||
"license": "BSD",
|
||||
"main": "lib/sax.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "isaacs",
|
||||
"email": "i@izs.me"
|
||||
}
|
||||
],
|
||||
"name": "sax",
|
||||
"optionalDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/sax-js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/index.js"
|
||||
},
|
||||
"version": "0.5.8"
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
require(__dirname).test(
|
||||
{ xml: "<root length='12345'></root>"
|
||||
, expect: [
|
||||
["attribute", {
|
||||
name: "length"
|
||||
, value: "12345"
|
||||
, prefix: ""
|
||||
, local: "length"
|
||||
, uri: ""
|
||||
}]
|
||||
, ["opentag", {
|
||||
name: "root"
|
||||
, prefix: ""
|
||||
, local: "root"
|
||||
, uri: ""
|
||||
, attributes: {
|
||||
length: {
|
||||
name: "length"
|
||||
, value: "12345"
|
||||
, prefix: ""
|
||||
, local: "length"
|
||||
, uri: ""
|
||||
}
|
||||
}
|
||||
, ns: {}
|
||||
, isSelfClosing: false
|
||||
}]
|
||||
, ["closetag", "root"]
|
||||
]
|
||||
, strict: true
|
||||
, opt: { xmlns: true }
|
||||
}
|
||||
)
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
// non-strict: no error
|
||||
require(__dirname).test
|
||||
( { xml : '<root attr1="first"attr2="second"/>'
|
||||
|
||||
, expect :
|
||||
[ [ "attribute", { name: 'attr1', value: 'first' } ]
|
||||
, [ "attribute", { name: 'attr2', value: 'second' } ]
|
||||
, [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
|
||||
, [ "closetag", "root" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : { lowercase: true }
|
||||
}
|
||||
)
|
||||
|
||||
// strict: should give an error, but still parse
|
||||
require(__dirname).test
|
||||
( { xml : '<root attr1="first"attr2="second"/>'
|
||||
|
||||
, expect :
|
||||
[ [ "attribute", { name: 'attr1', value: 'first' } ]
|
||||
, [ "error", "No whitespace between attributes\nLine: 0\nColumn: 20\nChar: a" ]
|
||||
, [ "attribute", { name: 'attr2', value: 'second' } ]
|
||||
, [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
|
||||
, [ "closetag", "root" ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { }
|
||||
}
|
||||
)
|
||||
|
||||
// strict: other cases should still pass
|
||||
require(__dirname).test
|
||||
( { xml : '<root attr1="first" attr2="second"/>'
|
||||
|
||||
, expect :
|
||||
[ [ "attribute", { name: 'attr1', value: 'first' } ]
|
||||
, [ "attribute", { name: 'attr2', value: 'second' } ]
|
||||
, [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
|
||||
, [ "closetag", "root" ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { }
|
||||
}
|
||||
)
|
||||
|
||||
// strict: other cases should still pass
|
||||
require(__dirname).test
|
||||
( { xml : '<root attr1="first"\nattr2="second"/>'
|
||||
|
||||
, expect :
|
||||
[ [ "attribute", { name: 'attr1', value: 'first' } ]
|
||||
, [ "attribute", { name: 'attr2', value: 'second' } ]
|
||||
, [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
|
||||
, [ "closetag", "root" ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { }
|
||||
}
|
||||
)
|
||||
|
||||
// strict: other cases should still pass
|
||||
require(__dirname).test
|
||||
( { xml : '<root attr1="first" attr2="second"/>'
|
||||
|
||||
, expect :
|
||||
[ [ "attribute", { name: 'attr1', value: 'first' } ]
|
||||
, [ "attribute", { name: 'attr2', value: 'second' } ]
|
||||
, [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
|
||||
, [ "closetag", "root" ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { }
|
||||
}
|
||||
)
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// set this really low so that I don't have to put 64 MB of xml in here.
|
||||
var sax = require("../lib/sax")
|
||||
var bl = sax.MAX_BUFFER_LENGTH
|
||||
sax.MAX_BUFFER_LENGTH = 5;
|
||||
|
||||
require(__dirname).test({
|
||||
expect : [
|
||||
["error", "Max buffer length exceeded: tagName\nLine: 0\nColumn: 15\nChar: "],
|
||||
["error", "Max buffer length exceeded: tagName\nLine: 0\nColumn: 30\nChar: "],
|
||||
["error", "Max buffer length exceeded: tagName\nLine: 0\nColumn: 45\nChar: "],
|
||||
["opentag", {
|
||||
"name": "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
"attributes": {},
|
||||
"isSelfClosing": false
|
||||
}],
|
||||
["text", "yo"],
|
||||
["closetag", "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"]
|
||||
]
|
||||
}).write("<abcdefghijklmn")
|
||||
.write("opqrstuvwxyzABC")
|
||||
.write("DEFGHIJKLMNOPQR")
|
||||
.write("STUVWXYZ>")
|
||||
.write("yo")
|
||||
.write("</abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ>")
|
||||
.close();
|
||||
sax.MAX_BUFFER_LENGTH = bl
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// default to uppercase
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<span class=\"test\" hello=\"world\"></span>"
|
||||
, expect :
|
||||
[ [ "attribute", { name: "CLASS", value: "test" } ]
|
||||
, [ "attribute", { name: "HELLO", value: "world" } ]
|
||||
, [ "opentag", { name: "SPAN",
|
||||
attributes: { CLASS: "test", HELLO: "world" },
|
||||
isSelfClosing: false } ]
|
||||
, [ "closetag", "SPAN" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
|
||||
// lowercase option : lowercase tag/attribute names
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<span class=\"test\" hello=\"world\"></span>"
|
||||
, expect :
|
||||
[ [ "attribute", { name: "class", value: "test" } ]
|
||||
, [ "attribute", { name: "hello", value: "world" } ]
|
||||
, [ "opentag", { name: "span",
|
||||
attributes: { class: "test", hello: "world" },
|
||||
isSelfClosing: false } ]
|
||||
, [ "closetag", "span" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : {lowercase:true}
|
||||
}
|
||||
)
|
||||
|
||||
// backward compatibility with old lowercasetags opt
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<span class=\"test\" hello=\"world\"></span>"
|
||||
, expect :
|
||||
[ [ "attribute", { name: "class", value: "test" } ]
|
||||
, [ "attribute", { name: "hello", value: "world" } ]
|
||||
, [ "opentag", { name: "span",
|
||||
attributes: { class: "test", hello: "world" },
|
||||
isSelfClosing: false } ]
|
||||
, [ "closetag", "span" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : {lowercasetags:true}
|
||||
}
|
||||
)
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
|
||||
require(__dirname).test({
|
||||
expect : [
|
||||
["opentag", {"name": "R","attributes": {}, "isSelfClosing": false}],
|
||||
["opencdata", undefined],
|
||||
["cdata", " this is character data "],
|
||||
["closecdata", undefined],
|
||||
["closetag", "R"]
|
||||
]
|
||||
}).write("<r><![CDATA[ this is ").write("character data ").write("]]></r>").close();
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
|
||||
require(__dirname).test({
|
||||
expect : [
|
||||
["opentag", {"name": "R","attributes": {}, "isSelfClosing": false}],
|
||||
["opencdata", undefined],
|
||||
["cdata", " this is "],
|
||||
["closecdata", undefined],
|
||||
["closetag", "R"]
|
||||
]
|
||||
})
|
||||
.write("<r><![CDATA[ this is ]")
|
||||
.write("]>")
|
||||
.write("</r>")
|
||||
.close();
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
|
||||
var p = require(__dirname).test({
|
||||
expect : [
|
||||
["opentag", {"name": "R","attributes": {}, "isSelfClosing": false}],
|
||||
["opencdata", undefined],
|
||||
["cdata", "[[[[[[[[]]]]]]]]"],
|
||||
["closecdata", undefined],
|
||||
["closetag", "R"]
|
||||
]
|
||||
})
|
||||
var x = "<r><![CDATA[[[[[[[[[]]]]]]]]]]></r>"
|
||||
for (var i = 0; i < x.length ; i ++) {
|
||||
p.write(x.charAt(i))
|
||||
}
|
||||
p.close();
|
||||
|
||||
|
||||
var p2 = require(__dirname).test({
|
||||
expect : [
|
||||
["opentag", {"name": "R","attributes": {}, "isSelfClosing": false}],
|
||||
["opencdata", undefined],
|
||||
["cdata", "[[[[[[[[]]]]]]]]"],
|
||||
["closecdata", undefined],
|
||||
["closetag", "R"]
|
||||
]
|
||||
})
|
||||
var x = "<r><![CDATA[[[[[[[[[]]]]]]]]]]></r>"
|
||||
p2.write(x).close();
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
|
||||
require(__dirname).test({
|
||||
expect : [
|
||||
["opentag", {"name": "R","attributes": {}, "isSelfClosing": false}],
|
||||
["opencdata", undefined],
|
||||
["cdata", " this is "],
|
||||
["closecdata", undefined],
|
||||
["opencdata", undefined],
|
||||
["cdata", "character data "],
|
||||
["closecdata", undefined],
|
||||
["closetag", "R"]
|
||||
]
|
||||
}).write("<r><![CDATA[ this is ]]>").write("<![CDA").write("T").write("A[")
|
||||
.write("character data ").write("]]></r>").close();
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
require(__dirname).test({
|
||||
xml : "<r><![CDATA[ this is character data ]]></r>",
|
||||
expect : [
|
||||
["opentag", {"name": "R","attributes": {}, "isSelfClosing": false}],
|
||||
["opencdata", undefined],
|
||||
["cdata", " this is character data "],
|
||||
["closecdata", undefined],
|
||||
["closetag", "R"]
|
||||
]
|
||||
});
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
require(__dirname).test({
|
||||
xml: '<Р>тест</Р>',
|
||||
expect: [
|
||||
['opentag', {'name':'Р', attributes:{}, isSelfClosing: false}],
|
||||
['text', 'тест'],
|
||||
['closetag', 'Р']
|
||||
]
|
||||
});
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<span id=\"hello\" id=\"there\"></span>"
|
||||
, expect :
|
||||
[ [ "attribute", { name: "ID", value: "hello" } ]
|
||||
, [ "opentag", { name: "SPAN",
|
||||
attributes: { ID: "hello" }, isSelfClosing: false } ]
|
||||
, [ "closetag", "SPAN" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
var assert = require('assert');
|
||||
var saxStream = require('../lib/sax').createStream();
|
||||
assert.doesNotThrow(function() {
|
||||
saxStream.end();
|
||||
});
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
require(__dirname).test({
|
||||
xml: '<r>⌋ ' +
|
||||
'♠ © → & ' +
|
||||
'< < < < < > ℜ ℘ €</r>',
|
||||
expect: [
|
||||
['opentag', {'name':'R', attributes:{}, isSelfClosing: false}],
|
||||
['text', '⌋ ♠ © → & < < < < < > ℜ ℘ €'],
|
||||
['closetag', 'R']
|
||||
]
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
var sax = require('../');
|
||||
var xml = '<r>';
|
||||
var text = '';
|
||||
for (var i in sax.ENTITIES) {
|
||||
xml += '&' + i + ';'
|
||||
text += sax.ENTITIES[i]
|
||||
}
|
||||
xml += '</r>'
|
||||
require(__dirname).test({
|
||||
xml: xml,
|
||||
expect: [
|
||||
['opentag', {'name':'R', attributes:{}, isSelfClosing: false}],
|
||||
['text', text],
|
||||
['closetag', 'R']
|
||||
]
|
||||
});
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
var parser = require(__dirname).test({
|
||||
expect: [
|
||||
['opentag', {'name':'T', attributes:{}, isSelfClosing: false}],
|
||||
['text', 'flush'],
|
||||
['text', 'rest'],
|
||||
['closetag', 'T'],
|
||||
]
|
||||
});
|
||||
|
||||
parser.write('<T>flush');
|
||||
parser.flush();
|
||||
parser.write('rest</T>');
|
||||
parser.close();
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
var globalsBefore = JSON.stringify(Object.keys(global))
|
||||
, util = require("util")
|
||||
, assert = require("assert")
|
||||
, fs = require("fs")
|
||||
, path = require("path")
|
||||
, sax = require("../lib/sax")
|
||||
|
||||
exports.sax = sax
|
||||
|
||||
// handy way to do simple unit tests
|
||||
// if the options contains an xml string, it'll be written and the parser closed.
|
||||
// otherwise, it's assumed that the test will write and close.
|
||||
exports.test = function test (options) {
|
||||
var xml = options.xml
|
||||
, parser = sax.parser(options.strict, options.opt)
|
||||
, expect = options.expect
|
||||
, e = 0
|
||||
sax.EVENTS.forEach(function (ev) {
|
||||
parser["on" + ev] = function (n) {
|
||||
if (process.env.DEBUG) {
|
||||
console.error({ expect: expect[e]
|
||||
, actual: [ev, n] })
|
||||
}
|
||||
if (e >= expect.length && (ev === "end" || ev === "ready")) return
|
||||
assert.ok( e < expect.length,
|
||||
"expectation #"+e+" "+util.inspect(expect[e])+"\n"+
|
||||
"Unexpected event: "+ev+" "+(n ? util.inspect(n) : ""))
|
||||
var inspected = n instanceof Error ? "\n"+ n.message : util.inspect(n)
|
||||
assert.equal(ev, expect[e][0],
|
||||
"expectation #"+e+"\n"+
|
||||
"Didn't get expected event\n"+
|
||||
"expect: "+expect[e][0] + " " +util.inspect(expect[e][1])+"\n"+
|
||||
"actual: "+ev+" "+inspected+"\n")
|
||||
if (ev === "error") assert.equal(n.message, expect[e][1])
|
||||
else assert.deepEqual(n, expect[e][1],
|
||||
"expectation #"+e+"\n"+
|
||||
"Didn't get expected argument\n"+
|
||||
"expect: "+expect[e][0] + " " +util.inspect(expect[e][1])+"\n"+
|
||||
"actual: "+ev+" "+inspected+"\n")
|
||||
e++
|
||||
if (ev === "error") parser.resume()
|
||||
}
|
||||
})
|
||||
if (xml) parser.write(xml).close()
|
||||
return parser
|
||||
}
|
||||
|
||||
if (module === require.main) {
|
||||
var running = true
|
||||
, failures = 0
|
||||
|
||||
function fail (file, er) {
|
||||
util.error("Failed: "+file)
|
||||
util.error(er.stack || er.message)
|
||||
failures ++
|
||||
}
|
||||
|
||||
fs.readdir(__dirname, function (error, files) {
|
||||
files = files.filter(function (file) {
|
||||
return (/\.js$/.exec(file) && file !== 'index.js')
|
||||
})
|
||||
var n = files.length
|
||||
, i = 0
|
||||
console.log("0.." + n)
|
||||
files.forEach(function (file) {
|
||||
// run this test.
|
||||
try {
|
||||
require(path.resolve(__dirname, file))
|
||||
var globalsAfter = JSON.stringify(Object.keys(global))
|
||||
if (globalsAfter !== globalsBefore) {
|
||||
var er = new Error("new globals introduced\n"+
|
||||
"expected: "+globalsBefore+"\n"+
|
||||
"actual: "+globalsAfter)
|
||||
globalsBefore = globalsAfter
|
||||
throw er
|
||||
}
|
||||
console.log("ok " + (++i) + " - " + file)
|
||||
} catch (er) {
|
||||
console.log("not ok "+ (++i) + " - " + file)
|
||||
fail(file, er)
|
||||
}
|
||||
})
|
||||
if (!failures) return console.log("#all pass")
|
||||
else return console.error(failures + " failure" + (failures > 1 ? "s" : ""))
|
||||
})
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<compileClassesResponse>"+
|
||||
"<result>"+
|
||||
"<bodyCrc>653724009</bodyCrc>"+
|
||||
"<column>-1</column>"+
|
||||
"<id>01pG0000002KoSUIA0</id>"+
|
||||
"<line>-1</line>"+
|
||||
"<name>CalendarController</name>"+
|
||||
"<success>true</success>"+
|
||||
"</result>"+
|
||||
"</compileClassesResponse>"
|
||||
|
||||
, expect :
|
||||
[ [ "opentag", { name: "COMPILECLASSESRESPONSE", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "opentag", { name : "RESULT", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "opentag", { name: "BODYCRC", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "text", "653724009" ]
|
||||
, [ "closetag", "BODYCRC" ]
|
||||
, [ "opentag", { name: "COLUMN", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "text", "-1" ]
|
||||
, [ "closetag", "COLUMN" ]
|
||||
, [ "opentag", { name: "ID", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "text", "01pG0000002KoSUIA0" ]
|
||||
, [ "closetag", "ID" ]
|
||||
, [ "opentag", {name: "LINE", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "text", "-1" ]
|
||||
, [ "closetag", "LINE" ]
|
||||
, [ "opentag", {name: "NAME", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "text", "CalendarController" ]
|
||||
, [ "closetag", "NAME" ]
|
||||
, [ "opentag", {name: "SUCCESS", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "text", "true" ]
|
||||
, [ "closetag", "SUCCESS" ]
|
||||
, [ "closetag", "RESULT" ]
|
||||
, [ "closetag", "COMPILECLASSESRESPONSE" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// https://github.com/isaacs/sax-js/issues/33
|
||||
require(__dirname).test
|
||||
( { xml : "<xml>\n"+
|
||||
"<!-- \n"+
|
||||
" comment with a single dash- in it\n"+
|
||||
"-->\n"+
|
||||
"<data/>\n"+
|
||||
"</xml>"
|
||||
|
||||
, expect :
|
||||
[ [ "opentag", { name: "xml", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "text", "\n" ]
|
||||
, [ "comment", " \n comment with a single dash- in it\n" ]
|
||||
, [ "text", "\n" ]
|
||||
, [ "opentag", { name: "data", attributes: {}, isSelfClosing: true } ]
|
||||
, [ "closetag", "data" ]
|
||||
, [ "text", "\n" ]
|
||||
, [ "closetag", "xml" ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// https://github.com/isaacs/sax-js/issues/35
|
||||
require(__dirname).test
|
||||
( { xml : "<xml>

\n"+
|
||||
"</xml>"
|
||||
|
||||
, expect :
|
||||
[ [ "opentag", { name: "xml", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "text", "\r\r\n" ]
|
||||
, [ "closetag", "xml" ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// https://github.com/isaacs/sax-js/issues/47
|
||||
require(__dirname).test
|
||||
( { xml : '<a href="query.svc?x=1&y=2&z=3"/>'
|
||||
, expect : [
|
||||
[ "attribute", { name:'HREF', value:"query.svc?x=1&y=2&z=3"} ],
|
||||
[ "opentag", { name: "A", attributes: { HREF:"query.svc?x=1&y=2&z=3"}, isSelfClosing: true } ],
|
||||
[ "closetag", "A" ]
|
||||
]
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// https://github.com/isaacs/sax-js/issues/49
|
||||
require(__dirname).test
|
||||
( { xml : "<xml><script>hello world</script></xml>"
|
||||
, expect :
|
||||
[ [ "opentag", { name: "xml", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "opentag", { name: "script", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "text", "hello world" ]
|
||||
, [ "closetag", "script" ]
|
||||
, [ "closetag", "xml" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : { lowercasetags: true, noscript: true }
|
||||
}
|
||||
)
|
||||
|
||||
require(__dirname).test
|
||||
( { xml : "<xml><script><![CDATA[hello world]]></script></xml>"
|
||||
, expect :
|
||||
[ [ "opentag", { name: "xml", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "opentag", { name: "script", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "opencdata", undefined ]
|
||||
, [ "cdata", "hello world" ]
|
||||
, [ "closecdata", undefined ]
|
||||
, [ "closetag", "script" ]
|
||||
, [ "closetag", "xml" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : { lowercasetags: true, noscript: true }
|
||||
}
|
||||
)
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// https://github.com/isaacs/sax-js/issues/49
|
||||
require(__dirname).test
|
||||
( { xml : "<?has unbalanced \"quotes?><xml>body</xml>"
|
||||
, expect :
|
||||
[ [ "processinginstruction", { name: "has", body: "unbalanced \"quotes" } ],
|
||||
[ "opentag", { name: "xml", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "text", "body" ]
|
||||
, [ "closetag", "xml" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : { lowercasetags: true, noscript: true }
|
||||
}
|
||||
)
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
var sax = require("../lib/sax"),
|
||||
assert = require("assert")
|
||||
|
||||
function testPosition(chunks, expectedEvents) {
|
||||
var parser = sax.parser();
|
||||
expectedEvents.forEach(function(expectation) {
|
||||
parser['on' + expectation[0]] = function() {
|
||||
for (var prop in expectation[1]) {
|
||||
assert.equal(parser[prop], expectation[1][prop]);
|
||||
}
|
||||
}
|
||||
});
|
||||
chunks.forEach(function(chunk) {
|
||||
parser.write(chunk);
|
||||
});
|
||||
};
|
||||
|
||||
testPosition(['<div>abcdefgh</div>'],
|
||||
[ ['opentag', { position: 5, startTagPosition: 1 }]
|
||||
, ['text', { position: 19, startTagPosition: 14 }]
|
||||
, ['closetag', { position: 19, startTagPosition: 14 }]
|
||||
]);
|
||||
|
||||
testPosition(['<div>abcde','fgh</div>'],
|
||||
[ ['opentag', { position: 5, startTagPosition: 1 }]
|
||||
, ['text', { position: 19, startTagPosition: 14 }]
|
||||
, ['closetag', { position: 19, startTagPosition: 14 }]
|
||||
]);
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
require(__dirname).test({
|
||||
xml : "<html><head><script>'<div>foo</div></'</script></head></html>",
|
||||
expect : [
|
||||
["opentag", {"name": "HTML","attributes": {}, isSelfClosing: false}],
|
||||
["opentag", {"name": "HEAD","attributes": {}, isSelfClosing: false}],
|
||||
["opentag", {"name": "SCRIPT","attributes": {}, isSelfClosing: false}],
|
||||
["script", "'<div>foo</div></'"],
|
||||
["closetag", "SCRIPT"],
|
||||
["closetag", "HEAD"],
|
||||
["closetag", "HTML"]
|
||||
]
|
||||
});
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
require(__dirname).test({
|
||||
xml : "<html><head><script>if (1 < 0) { console.log('elo there'); }</script></head></html>",
|
||||
expect : [
|
||||
["opentag", {"name": "HTML","attributes": {}, "isSelfClosing": false}],
|
||||
["opentag", {"name": "HEAD","attributes": {}, "isSelfClosing": false}],
|
||||
["opentag", {"name": "SCRIPT","attributes": {}, "isSelfClosing": false}],
|
||||
["script", "if (1 < 0) { console.log('elo there'); }"],
|
||||
["closetag", "SCRIPT"],
|
||||
["closetag", "HEAD"],
|
||||
["closetag", "HTML"]
|
||||
]
|
||||
});
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
|
||||
require(__dirname).test({
|
||||
xml :
|
||||
"<root>"+
|
||||
"<child>" +
|
||||
"<haha />" +
|
||||
"</child>" +
|
||||
"<monkey>" +
|
||||
"=(|)" +
|
||||
"</monkey>" +
|
||||
"</root>",
|
||||
expect : [
|
||||
["opentag", {
|
||||
"name": "root",
|
||||
"attributes": {},
|
||||
"isSelfClosing": false
|
||||
}],
|
||||
["opentag", {
|
||||
"name": "child",
|
||||
"attributes": {},
|
||||
"isSelfClosing": false
|
||||
}],
|
||||
["opentag", {
|
||||
"name": "haha",
|
||||
"attributes": {},
|
||||
"isSelfClosing": true
|
||||
}],
|
||||
["closetag", "haha"],
|
||||
["closetag", "child"],
|
||||
["opentag", {
|
||||
"name": "monkey",
|
||||
"attributes": {},
|
||||
"isSelfClosing": false
|
||||
}],
|
||||
["text", "=(|)"],
|
||||
["closetag", "monkey"],
|
||||
["closetag", "root"],
|
||||
["end"],
|
||||
["ready"]
|
||||
],
|
||||
strict : true,
|
||||
opt : {}
|
||||
});
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
|
||||
require(__dirname).test({
|
||||
xml :
|
||||
"<root>"+
|
||||
"<child>" +
|
||||
"<haha />" +
|
||||
"</child>" +
|
||||
"<monkey>" +
|
||||
"=(|)" +
|
||||
"</monkey>" +
|
||||
"</root>",
|
||||
expect : [
|
||||
["opentag", {
|
||||
"name": "ROOT",
|
||||
"attributes": {},
|
||||
"isSelfClosing": false
|
||||
}],
|
||||
["opentag", {
|
||||
"name": "CHILD",
|
||||
"attributes": {},
|
||||
"isSelfClosing": false
|
||||
}],
|
||||
["opentag", {
|
||||
"name": "HAHA",
|
||||
"attributes": {},
|
||||
"isSelfClosing": true
|
||||
}],
|
||||
["closetag", "HAHA"],
|
||||
["closetag", "CHILD"],
|
||||
["opentag", {
|
||||
"name": "MONKEY",
|
||||
"attributes": {},
|
||||
"isSelfClosing": false
|
||||
}],
|
||||
["text", "=(|)"],
|
||||
["closetag", "MONKEY"],
|
||||
["closetag", "ROOT"],
|
||||
["end"],
|
||||
["ready"]
|
||||
],
|
||||
strict : false,
|
||||
opt : {}
|
||||
});
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
|
||||
require(__dirname).test({
|
||||
xml :
|
||||
"<root> "+
|
||||
"<haha /> "+
|
||||
"<haha/> "+
|
||||
"<monkey> "+
|
||||
"=(|) "+
|
||||
"</monkey>"+
|
||||
"</root> ",
|
||||
expect : [
|
||||
["opentag", {name:"ROOT", attributes:{}, isSelfClosing: false}],
|
||||
["opentag", {name:"HAHA", attributes:{}, isSelfClosing: true}],
|
||||
["closetag", "HAHA"],
|
||||
["opentag", {name:"HAHA", attributes:{}, isSelfClosing: true}],
|
||||
["closetag", "HAHA"],
|
||||
// ["opentag", {name:"HAHA", attributes:{}}],
|
||||
// ["closetag", "HAHA"],
|
||||
["opentag", {name:"MONKEY", attributes:{}, isSelfClosing: false}],
|
||||
["text", "=(|)"],
|
||||
["closetag", "MONKEY"],
|
||||
["closetag", "ROOT"]
|
||||
],
|
||||
opt : { trim : true }
|
||||
});
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// stray ending tags should just be ignored in non-strict mode.
|
||||
// https://github.com/isaacs/sax-js/issues/32
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<a><b></c></b></a>"
|
||||
, expect :
|
||||
[ [ "opentag", { name: "A", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "opentag", { name: "B", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "text", "</c>" ]
|
||||
, [ "closetag", "B" ]
|
||||
, [ "closetag", "A" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
|
||||
require(__dirname).test({
|
||||
xml :
|
||||
"<root attrib>",
|
||||
expect : [
|
||||
["attribute", {name:"ATTRIB", value:"attrib"}],
|
||||
["opentag", {name:"ROOT", attributes:{"ATTRIB":"attrib"}, isSelfClosing: false}]
|
||||
],
|
||||
opt : { trim : true }
|
||||
});
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
|
||||
require(__dirname).test({
|
||||
xml : "<span>Welcome,</span> to monkey land",
|
||||
expect : [
|
||||
["opentag", {
|
||||
"name": "SPAN",
|
||||
"attributes": {},
|
||||
isSelfClosing: false
|
||||
}],
|
||||
["text", "Welcome,"],
|
||||
["closetag", "SPAN"],
|
||||
["text", " to monkey land"],
|
||||
["end"],
|
||||
["ready"]
|
||||
],
|
||||
strict : false,
|
||||
opt : {}
|
||||
});
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
require(__dirname).test
|
||||
( { xml : "<root>"
|
||||
|
||||
, expect :
|
||||
[ [ "opentag", { name: "root", attributes: {}, isSelfClosing: false } ]
|
||||
, [ "error", "Unclosed root tag\nLine: 0\nColumn: 6\nChar: " ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// unquoted attributes should be ok in non-strict mode
|
||||
// https://github.com/isaacs/sax-js/issues/31
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<span class=test hello=world></span>"
|
||||
, expect :
|
||||
[ [ "attribute", { name: "CLASS", value: "test" } ]
|
||||
, [ "attribute", { name: "HELLO", value: "world" } ]
|
||||
, [ "opentag", { name: "SPAN",
|
||||
attributes: { CLASS: "test", HELLO: "world" },
|
||||
isSelfClosing: false } ]
|
||||
, [ "closetag", "SPAN" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
var assert = require('assert')
|
||||
var saxStream = require('../lib/sax').createStream()
|
||||
|
||||
var b = new Buffer('误')
|
||||
|
||||
saxStream.on('text', function(text) {
|
||||
assert.equal(text, b.toString())
|
||||
})
|
||||
|
||||
saxStream.write(new Buffer('<test><a>'))
|
||||
saxStream.write(b.slice(0, 1))
|
||||
saxStream.write(b.slice(1))
|
||||
saxStream.write(new Buffer('</a><b>'))
|
||||
saxStream.write(b.slice(0, 2))
|
||||
saxStream.write(b.slice(2))
|
||||
saxStream.write(new Buffer('</b><c>'))
|
||||
saxStream.write(b)
|
||||
saxStream.write(new Buffer('</c>'))
|
||||
saxStream.write(Buffer.concat([new Buffer('<d>'), b.slice(0, 1)]))
|
||||
saxStream.end(Buffer.concat([b.slice(1), new Buffer('</d></test>')]))
|
||||
|
||||
var saxStream2 = require('../lib/sax').createStream()
|
||||
|
||||
saxStream2.on('text', function(text) {
|
||||
assert.equal(text, '�')
|
||||
});
|
||||
|
||||
saxStream2.write(new Buffer('<e>'));
|
||||
saxStream2.write(new Buffer([0xC0]));
|
||||
saxStream2.write(new Buffer('</e>'));
|
||||
saxStream2.write(Buffer.concat([new Buffer('<f>'), b.slice(0,1)]));
|
||||
saxStream2.end();
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<xmlns/>"
|
||||
, expect :
|
||||
[ [ "opentag", { name: "xmlns", uri: "", prefix: "", local: "xmlns",
|
||||
attributes: {}, ns: {},
|
||||
isSelfClosing: true}
|
||||
],
|
||||
["closetag", "xmlns"]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { xmlns: true }
|
||||
}
|
||||
);
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
var t = require(__dirname)
|
||||
|
||||
, xmls = // should be the same both ways.
|
||||
[ "<parent xmlns:a='http://ATTRIBUTE' a:attr='value' />"
|
||||
, "<parent a:attr='value' xmlns:a='http://ATTRIBUTE' />" ]
|
||||
|
||||
, ex1 =
|
||||
[ [ "opennamespace"
|
||||
, { prefix: "a"
|
||||
, uri: "http://ATTRIBUTE"
|
||||
}
|
||||
]
|
||||
, [ "attribute"
|
||||
, { name: "xmlns:a"
|
||||
, value: "http://ATTRIBUTE"
|
||||
, prefix: "xmlns"
|
||||
, local: "a"
|
||||
, uri: "http://www.w3.org/2000/xmlns/"
|
||||
}
|
||||
]
|
||||
, [ "attribute"
|
||||
, { name: "a:attr"
|
||||
, local: "attr"
|
||||
, prefix: "a"
|
||||
, uri: "http://ATTRIBUTE"
|
||||
, value: "value"
|
||||
}
|
||||
]
|
||||
, [ "opentag"
|
||||
, { name: "parent"
|
||||
, uri: ""
|
||||
, prefix: ""
|
||||
, local: "parent"
|
||||
, attributes:
|
||||
{ "a:attr":
|
||||
{ name: "a:attr"
|
||||
, local: "attr"
|
||||
, prefix: "a"
|
||||
, uri: "http://ATTRIBUTE"
|
||||
, value: "value"
|
||||
}
|
||||
, "xmlns:a":
|
||||
{ name: "xmlns:a"
|
||||
, local: "a"
|
||||
, prefix: "xmlns"
|
||||
, uri: "http://www.w3.org/2000/xmlns/"
|
||||
, value: "http://ATTRIBUTE"
|
||||
}
|
||||
}
|
||||
, ns: {"a": "http://ATTRIBUTE"}
|
||||
, isSelfClosing: true
|
||||
}
|
||||
]
|
||||
, ["closetag", "parent"]
|
||||
, ["closenamespace", { prefix: "a", uri: "http://ATTRIBUTE" }]
|
||||
]
|
||||
|
||||
// swap the order of elements 2 and 1
|
||||
, ex2 = [ex1[0], ex1[2], ex1[1]].concat(ex1.slice(3))
|
||||
, expected = [ex1, ex2]
|
||||
|
||||
xmls.forEach(function (x, i) {
|
||||
t.test({ xml: x
|
||||
, expect: expected[i]
|
||||
, strict: true
|
||||
, opt: { xmlns: true }
|
||||
})
|
||||
})
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<root xmlns:x='x1' xmlns:y='y1' x:a='x1' y:a='y1'>"+
|
||||
"<rebind xmlns:x='x2'>"+
|
||||
"<check x:a='x2' y:a='y1'/>"+
|
||||
"</rebind>"+
|
||||
"<check x:a='x1' y:a='y1'/>"+
|
||||
"</root>"
|
||||
|
||||
, expect :
|
||||
[ [ "opennamespace", { prefix: "x", uri: "x1" } ]
|
||||
, [ "opennamespace", { prefix: "y", uri: "y1" } ]
|
||||
, [ "attribute", { name: "xmlns:x", value: "x1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } ]
|
||||
, [ "attribute", { name: "xmlns:y", value: "y1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "y" } ]
|
||||
, [ "attribute", { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" } ]
|
||||
, [ "attribute", { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } ]
|
||||
, [ "opentag", { name: "root", uri: "", prefix: "", local: "root",
|
||||
attributes: { "xmlns:x": { name: "xmlns:x", value: "x1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" }
|
||||
, "xmlns:y": { name: "xmlns:y", value: "y1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "y" }
|
||||
, "x:a": { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" }
|
||||
, "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } },
|
||||
ns: { x: 'x1', y: 'y1' },
|
||||
isSelfClosing: false } ]
|
||||
|
||||
, [ "opennamespace", { prefix: "x", uri: "x2" } ]
|
||||
, [ "attribute", { name: "xmlns:x", value: "x2", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } ]
|
||||
, [ "opentag", { name: "rebind", uri: "", prefix: "", local: "rebind",
|
||||
attributes: { "xmlns:x": { name: "xmlns:x", value: "x2", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } },
|
||||
ns: { x: 'x2' },
|
||||
isSelfClosing: false } ]
|
||||
|
||||
, [ "attribute", { name: "x:a", value: "x2", uri: "x2", prefix: "x", local: "a" } ]
|
||||
, [ "attribute", { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } ]
|
||||
, [ "opentag", { name: "check", uri: "", prefix: "", local: "check",
|
||||
attributes: { "x:a": { name: "x:a", value: "x2", uri: "x2", prefix: "x", local: "a" }
|
||||
, "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } },
|
||||
ns: { x: 'x2' },
|
||||
isSelfClosing: true } ]
|
||||
|
||||
, [ "closetag", "check" ]
|
||||
|
||||
, [ "closetag", "rebind" ]
|
||||
, [ "closenamespace", { prefix: "x", uri: "x2" } ]
|
||||
|
||||
, [ "attribute", { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" } ]
|
||||
, [ "attribute", { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } ]
|
||||
, [ "opentag", { name: "check", uri: "", prefix: "", local: "check",
|
||||
attributes: { "x:a": { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" }
|
||||
, "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } },
|
||||
ns: { x: 'x1', y: 'y1' },
|
||||
isSelfClosing: true } ]
|
||||
, [ "closetag", "check" ]
|
||||
|
||||
, [ "closetag", "root" ]
|
||||
, [ "closenamespace", { prefix: "x", uri: "x1" } ]
|
||||
, [ "closenamespace", { prefix: "y", uri: "y1" } ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { xmlns: true }
|
||||
}
|
||||
)
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<root>"+
|
||||
"<plain attr='normal'/>"+
|
||||
"<ns1 xmlns='uri:default'>"+
|
||||
"<plain attr='normal'/>"+
|
||||
"</ns1>"+
|
||||
"<ns2 xmlns:a='uri:nsa'>"+
|
||||
"<plain attr='normal'/>"+
|
||||
"<a:ns a:attr='namespaced'/>"+
|
||||
"</ns2>"+
|
||||
"</root>"
|
||||
|
||||
, expect :
|
||||
[ [ "opentag", { name: "root", prefix: "", local: "root", uri: "",
|
||||
attributes: {}, ns: {}, isSelfClosing: false } ]
|
||||
|
||||
, [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ]
|
||||
, [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "",
|
||||
attributes: { "attr": { name: "attr", value: "normal", uri: "", prefix: "", local: "attr", uri: "" } },
|
||||
ns: {}, isSelfClosing: true } ]
|
||||
, [ "closetag", "plain" ]
|
||||
|
||||
, [ "opennamespace", { prefix: "", uri: "uri:default" } ]
|
||||
|
||||
, [ "attribute", { name: "xmlns", value: "uri:default", prefix: "xmlns", local: "", uri: "http://www.w3.org/2000/xmlns/" } ]
|
||||
, [ "opentag", { name: "ns1", prefix: "", local: "ns1", uri: "uri:default",
|
||||
attributes: { "xmlns": { name: "xmlns", value: "uri:default", prefix: "xmlns", local: "", uri: "http://www.w3.org/2000/xmlns/" } },
|
||||
ns: { "": "uri:default" }, isSelfClosing: false } ]
|
||||
|
||||
, [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ]
|
||||
, [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "uri:default", ns: { '': 'uri:default' },
|
||||
attributes: { "attr": { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } },
|
||||
isSelfClosing: true } ]
|
||||
, [ "closetag", "plain" ]
|
||||
|
||||
, [ "closetag", "ns1" ]
|
||||
|
||||
, [ "closenamespace", { prefix: "", uri: "uri:default" } ]
|
||||
|
||||
, [ "opennamespace", { prefix: "a", uri: "uri:nsa" } ]
|
||||
|
||||
, [ "attribute", { name: "xmlns:a", value: "uri:nsa", prefix: "xmlns", local: "a", uri: "http://www.w3.org/2000/xmlns/" } ]
|
||||
|
||||
, [ "opentag", { name: "ns2", prefix: "", local: "ns2", uri: "",
|
||||
attributes: { "xmlns:a": { name: "xmlns:a", value: "uri:nsa", prefix: "xmlns", local: "a", uri: "http://www.w3.org/2000/xmlns/" } },
|
||||
ns: { a: "uri:nsa" }, isSelfClosing: false } ]
|
||||
|
||||
, [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ]
|
||||
, [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "",
|
||||
attributes: { "attr": { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } },
|
||||
ns: { a: 'uri:nsa' },
|
||||
isSelfClosing: true } ]
|
||||
, [ "closetag", "plain" ]
|
||||
|
||||
, [ "attribute", { name: "a:attr", value: "namespaced", prefix: "a", local: "attr", uri: "uri:nsa" } ]
|
||||
, [ "opentag", { name: "a:ns", prefix: "a", local: "ns", uri: "uri:nsa",
|
||||
attributes: { "a:attr": { name: "a:attr", value: "namespaced", prefix: "a", local: "attr", uri: "uri:nsa" } },
|
||||
ns: { a: 'uri:nsa' },
|
||||
isSelfClosing: true } ]
|
||||
, [ "closetag", "a:ns" ]
|
||||
|
||||
, [ "closetag", "ns2" ]
|
||||
|
||||
, [ "closenamespace", { prefix: "a", uri: "uri:nsa" } ]
|
||||
|
||||
, [ "closetag", "root" ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { xmlns: true }
|
||||
}
|
||||
)
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
require(__dirname).test(
|
||||
{ strict : true
|
||||
, opt : { xmlns: true }
|
||||
, expect :
|
||||
[ [ "error", "Unbound namespace prefix: \"unbound:root\"\nLine: 0\nColumn: 15\nChar: >"]
|
||||
, [ "opentag", { name: "unbound:root", uri: "unbound", prefix: "unbound", local: "root"
|
||||
, attributes: {}, ns: {}, isSelfClosing: true } ]
|
||||
, [ "closetag", "unbound:root" ]
|
||||
]
|
||||
}
|
||||
).write("<unbound:root/>");
|
||||
|
||||
require(__dirname).test(
|
||||
{ strict : true
|
||||
, opt : { xmlns: true }
|
||||
, expect :
|
||||
[ [ "opennamespace", { prefix: "unbound", uri: "someuri" } ]
|
||||
, [ "attribute", { name: 'xmlns:unbound', value: 'someuri'
|
||||
, prefix: 'xmlns', local: 'unbound'
|
||||
, uri: 'http://www.w3.org/2000/xmlns/' } ]
|
||||
, [ "opentag", { name: "unbound:root", uri: "someuri", prefix: "unbound", local: "root"
|
||||
, attributes: { 'xmlns:unbound': {
|
||||
name: 'xmlns:unbound'
|
||||
, value: 'someuri'
|
||||
, prefix: 'xmlns'
|
||||
, local: 'unbound'
|
||||
, uri: 'http://www.w3.org/2000/xmlns/' } }
|
||||
, ns: { "unbound": "someuri" }, isSelfClosing: true } ]
|
||||
, [ "closetag", "unbound:root" ]
|
||||
, [ "closenamespace", { prefix: 'unbound', uri: 'someuri' }]
|
||||
]
|
||||
}
|
||||
).write("<unbound:root xmlns:unbound=\"someuri\"/>");
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
|
||||
require(__dirname).test(
|
||||
{ strict : true
|
||||
, opt : { xmlns: true }
|
||||
, expect :
|
||||
[ ["error", "Unbound namespace prefix: \"unbound\"\nLine: 0\nColumn: 28\nChar: >"]
|
||||
|
||||
, [ "attribute", { name: "unbound:attr", value: "value", uri: "unbound", prefix: "unbound", local: "attr" } ]
|
||||
, [ "opentag", { name: "root", uri: "", prefix: "", local: "root",
|
||||
attributes: { "unbound:attr": { name: "unbound:attr", value: "value", uri: "unbound", prefix: "unbound", local: "attr" } },
|
||||
ns: {}, isSelfClosing: true } ]
|
||||
, [ "closetag", "root" ]
|
||||
]
|
||||
}
|
||||
).write("<root unbound:attr='value'/>")
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
var xmlns_attr =
|
||||
{
|
||||
name: "xmlns", value: "http://foo", prefix: "xmlns",
|
||||
local: "", uri : "http://www.w3.org/2000/xmlns/"
|
||||
};
|
||||
|
||||
var attr_attr =
|
||||
{
|
||||
name: "attr", value: "bar", prefix: "",
|
||||
local : "attr", uri : ""
|
||||
};
|
||||
|
||||
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<elm xmlns='http://foo' attr='bar'/>"
|
||||
, expect :
|
||||
[ [ "opennamespace", { prefix: "", uri: "http://foo" } ]
|
||||
, [ "attribute", xmlns_attr ]
|
||||
, [ "attribute", attr_attr ]
|
||||
, [ "opentag", { name: "elm", prefix: "", local: "elm", uri : "http://foo",
|
||||
ns : { "" : "http://foo" },
|
||||
attributes: { xmlns: xmlns_attr, attr: attr_attr },
|
||||
isSelfClosing: true } ]
|
||||
, [ "closetag", "elm" ]
|
||||
, [ "closenamespace", { prefix: "", uri: "http://foo"} ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : {xmlns: true}
|
||||
}
|
||||
)
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
require(__dirname).test(
|
||||
{ xml : "<root xml:lang='en'/>"
|
||||
, expect :
|
||||
[ [ "attribute"
|
||||
, { name: "xml:lang"
|
||||
, local: "lang"
|
||||
, prefix: "xml"
|
||||
, uri: "http://www.w3.org/XML/1998/namespace"
|
||||
, value: "en"
|
||||
}
|
||||
]
|
||||
, [ "opentag"
|
||||
, { name: "root"
|
||||
, uri: ""
|
||||
, prefix: ""
|
||||
, local: "root"
|
||||
, attributes:
|
||||
{ "xml:lang":
|
||||
{ name: "xml:lang"
|
||||
, local: "lang"
|
||||
, prefix: "xml"
|
||||
, uri: "http://www.w3.org/XML/1998/namespace"
|
||||
, value: "en"
|
||||
}
|
||||
}
|
||||
, ns: {}
|
||||
, isSelfClosing: true
|
||||
}
|
||||
]
|
||||
, ["closetag", "root"]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { xmlns: true }
|
||||
}
|
||||
)
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
require(__dirname).test(
|
||||
{ xml : "<xml:root/>"
|
||||
, expect :
|
||||
[
|
||||
[ "opentag"
|
||||
, { name: "xml:root"
|
||||
, uri: "http://www.w3.org/XML/1998/namespace"
|
||||
, prefix: "xml"
|
||||
, local: "root"
|
||||
, attributes: {}
|
||||
, ns: {}
|
||||
, isSelfClosing: true
|
||||
}
|
||||
]
|
||||
, ["closetag", "xml:root"]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { xmlns: true }
|
||||
}
|
||||
)
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
require(__dirname).test(
|
||||
{ xml : "<xml:root xmlns:xml='ERROR'/>"
|
||||
, expect :
|
||||
[ ["error"
|
||||
, "xml: prefix must be bound to http://www.w3.org/XML/1998/namespace\n"
|
||||
+ "Actual: ERROR\n"
|
||||
+ "Line: 0\nColumn: 27\nChar: '"
|
||||
]
|
||||
, [ "attribute"
|
||||
, { name: "xmlns:xml"
|
||||
, local: "xml"
|
||||
, prefix: "xmlns"
|
||||
, uri: "http://www.w3.org/2000/xmlns/"
|
||||
, value: "ERROR"
|
||||
}
|
||||
]
|
||||
, [ "opentag"
|
||||
, { name: "xml:root"
|
||||
, uri: "http://www.w3.org/XML/1998/namespace"
|
||||
, prefix: "xml"
|
||||
, local: "root"
|
||||
, attributes:
|
||||
{ "xmlns:xml":
|
||||
{ name: "xmlns:xml"
|
||||
, local: "xml"
|
||||
, prefix: "xmlns"
|
||||
, uri: "http://www.w3.org/2000/xmlns/"
|
||||
, value: "ERROR"
|
||||
}
|
||||
}
|
||||
, ns: {}
|
||||
, isSelfClosing: true
|
||||
}
|
||||
]
|
||||
, ["closetag", "xml:root"]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { xmlns: true }
|
||||
}
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user