Common Lisp Package: PITHY-XML

README:

FUNCTION

Public

CAMEL (STREAM STRING &OPTIONAL COLON AT)

Convert a hyphenated-name to CamelCase, unless it already is. Encode XML entities. Convert '%' to ':'.

ENTITY (STREAM CONTENT &OPTIONAL COLON AT)

Print CONTENT to STREAM, encoding characters with XML entities according to *XML-ENTITIES*.

FIND-DESCENDANT (PARENT &REST PATH)

Locate a descendant of PARENT according to PATH. Each path element either names the child element, or is an integer child index.

MAP-ELEMENTS (FUNCTION DOCUMENT)

For each element in DOCUMENT, apply FUNCTION to the name and attribute plist. Recurse into contents when FUNCTION returns true.

PARSE-XML-ELEMENT (ELEMENT)

Return the element's contents, attributes, and name.

READ-XML (STREAM-OR-STRING &KEY (TYPE 'XML-ELEMENT) ((DEFAULT-NAMESPACE *DEFAULT-NAMESPACE*) KEYWORD) ((NAMESPACE-BINDINGS *NAMESPACE-BINDINGS*) *NAMESPACE-BINDINGS*) PREPEND)

Read the first XML element from STREAM-OR-STRING that matches TYPE.

READ-XML-DOCUMENT (DOCUMENT-STREAM-OR-STRING &REST KEY-ARGS &KEY (SET-EXTERNAL-FORMAT *DEFAULT-SET-EXTERNAL-FORMAT*) TYPE NAMESPACE-MODE DEFAULT-NAMESPACE NAMESPACE-BINDINGS)

Like READ-XML, but process encoding directives by applying SET-EXTERNAL-FORMAT to the stream and encoding, if specified in the document.

READ-XML-FILE (PATH &KEY (EXTERNAL-FORMAT (XML-FILE-ENCODING PATH)) (TYPE 'XML-ELEMENT) ((XML-ENTITIES *XML-ENTITIES*) *XML-ENTITIES*))

Read all the contents from file at PATH.

XML-INTERN (STRING &KEY STRINGP)

Decamelize, intern, etc. STRING into a symbol, or just the string if STRINGP is true.

Private

DEFAULT-SET-EXTERNAL-FORMAT (STREAM ENCODING)

Attempt to verify that STREAM is compatible with ENCODING.

READ-SCHEMA-SYMBOLS (PATH &KEY EXPECT-NAMESPACE)

Extract the relevant symbols from an XML schema in PATH.

XML-FILE-ENCODING (PATH)

Return the file encoding declared for the file at PATH, if any.

Undocumented

PARSE-DOCTYPE (DOCTYPE)

UNQUOTE (STRING)

MACRO

Public

DEFINE-XML-NAMESPACE (NAME URL &REST OPTIONS)

Define a package/namespace. NAME is a short-hand name, while URL is the canonical XML namespace name which will become a nickname for the package. Extra options are ACRONYMS which lists a set of acronyms (for tweaking the XML<->symbol mapping), and LOCK which is whether symbols should automatically be interned for this package/namespace by READ-XML.

DEFINE-XML-NAMESPACE-BY-SCHEMA (NAME URL SCHEMA-PATH &REST OPTIONS)

Declare a namespace by reading symbols from an XML schema file. Defaults :LOCK to true.

VARIABLE

Public

*DEFAULT-SET-EXTERNAL-FORMAT*

Function to be called to set a STREAM's EXTERNAL-FORMAT.

*MAKE-XML-NAMESPACE*

Called whenver a non-existing namespace is encountered. Return package to use.

*NAMESPACE-BINDINGS*

The active mappings from qualifiers to namespaces.

*XML-ACRONYMS*

Default list of acronyms. These strings will not be (de)camelized.

Undocumented

*XML-ENTITIES*

Private

*INTERN-UNKNOWN-SYMBOLS*

When encountering a symbol that doesn't already exist in the namespace, and LOCK us undefined for the namespace, intern it?

*NAMESPACE-PLISTS*

Properties for each namespace/package.

*PRINT-NO-NAMESPACE-BINDING*

What to do when printing a symbol and there is no current binding for the namespace? If NIL, fail. If T, print name without namespace prefix. If :PACKAGE-NAME, use the package's name as namespace prefix.

*UNKNOWN-PACKAGE-IS-DEFAULT-NAMESPACE-P*

When encountering an unknown package, map to default namespace?

Undocumented

*DEFAULT-NAMESPACE*