Namespace funnyqt.xmltg

Convert XML to DOM-like TGraphs.

Other Namespaces

Show/Hide
funnyqt.bidi
Bidirectional transformations (BX).
funnyqt.coevo.tg
Co-Evolution transformations on TGraphs.
funnyqt.edn
Printing/persisting and reading/loading query results and transformation traces as EDN.
funnyqt.emf
Core functions for accessing and manipulating EMF models.
funnyqt.extensional
Specify models extensionally.
funnyqt.generic
Generic protocols extended upon many different types, and generic functions.
funnyqt.in-place
In-place transformation stuff.
funnyqt.model2model
Rule-base out-place transformations similar to ATL or QVTo.
funnyqt.pmatch
Graph Pattern Matching on arbitrary models.
funnyqt.polyfns
Polymorphic functions dispatching on types of model elements.
funnyqt.query
Generic query functions like regular path expressions & quantified expressions.
funnyqt.query.emf
EMF-specific query functions
funnyqt.query.tg
TG-specific query functions
funnyqt.relational
Relational Model Querying.
funnyqt.tg
Core functions for accessing and manipulating TGraphs.
funnyqt.utils
Generic utility functions, e.g., for signaling errors, debugging, and profiling,
funnyqt.visualization
Model visualization functions.
Index Page
Alphabetic Var Index

Public Vars

Usage Documentation

Show/Hide
Convert XML to DOM-like TGraphs.

The DOM-like schema looks like this:

  https://raw.github.com/jgralab/funnyqt/master/resources/xml-schema.png

To transform an XML document to a DOM-like TGraph, use

  (xml2xml-graph "example.xml")

If the XML file has a DTD which describes what attributes are IDs, IDREFs, and
IDREFS, all references will be represented as References edges in the Graph.

If the XML file has no DTD, you can influence the resolution by providing an
`attr-type-fn` and/or an `text-type-fn` as documented in `xml2xml-graph`.
Back to top

Details of Public Vars

Function: attribute-value

Arglists:
=========

  (attribute-value elem attr-name)

Docstring:
==========

  Returns the value of `elem`s xml attribute `attr-name`.
  First the `attr-name' is compared to the declared name.  If no attribute
  matches, the local names are compared, too.
Back to top View Source

Function: children

Arglists:
=========

  (children e)
  (children e qn)

Docstring:
==========

  Returns the children Element vertices of Element vertex `e`.
  May be restricted to elements of type `qn`, a qualified name (see
  `qualified-name`), an expanded (see `expanded-name`) or declared name (see
  `declared-name`), or a local name.
Back to top View Source

Function: declared-name

Arglists:
=========

  (declared-name e)

Docstring:
==========

  Returns the name of the given Element or Attribute, possibly prefixed with its namespace.
  If it doesn't declare a namespace itself, the local name is returned.
Back to top View Source

Function: describe-element

Arglists:
=========

  (describe-element e)
  (describe-element e with-children)

Docstring:
==========

  Returns a map describing the given xml Element vertex `e`.
Back to top View Source

Function: expanded-name

Arglists:
=========

  (expanded-name e)

Docstring:
==========

  Returns the expanded name of Element or Attribute `e` in the form "{nsURI}localName",
  or just "localName" if it's not namespaced.
Back to top View Source

Function: ns-prefix

Arglists:
=========

  (ns-prefix e)

Docstring:
==========

  Returns the namespace prefix of the given Element or Attribute.
  If that doesn't declare a namespace itself, returns the namespace of its
  container (recursively if needed).
Back to top View Source

Function: ns-uri

Arglists:
=========

  (ns-uri e)

Docstring:
==========

  Returns the namespace URI of the given Element or Attribute.
  Lookup is done recursively.
Back to top View Source

Function: qualified-name

Arglists:
=========

  (qualified-name e)

Docstring:
==========

  Returns the qualified name of the give Element, i.e., "nsprefix:name".
Back to top View Source

Function: siblings

Arglists:
=========

  (siblings e)
  (siblings e qn)

Docstring:
==========

  Returns the sibling Element vertices of Element or CharContent `e`.
  May be restricted to elements of the given type `qn`, , a qualified name (see
  `qualified-name`), an expanded (see `expanded-name`) or declared name (see
  `declared-name`), or a local name.

  The result is a vector of two component seqs:

    [left-siblings right-siblings]

  left-siblings is a seq of siblings that occur left of (or above) `e`, and
  right-siblings is a seq of siblings that occur right of (or below) `e`.  `e`
  itself is not included.
Back to top View Source

Function: xml-graph2xml

Arglists:
=========

  (xml-graph2xml g f)

Docstring:
==========

  Serializes the given XMLGraph `g` back to an XML document `f`.
Back to top View Source

Function: xml2xml-graph

Arglists:
=========

  (xml2xml-graph f)
  (xml2xml-graph f attr-type-fn)
  (xml2xml-graph f attr-type-fn text-type-fn)
  (xml2xml-graph f attr-type-fn text-type-fn xml-graph)

Docstring:
==========

  Parse the XML file `f` into a TGraph conforming the generic XML schema.
  IDREF resolving, which is needed for creating References edges, works
  automatically only for XML files containing a DTD describing them.

  If you want IDREFs resolved anyway, you have to provide an `attr-type-fn`
  that takes 3 arguments: an element's expanded name, an attribute name, and
  that attribute's value.  It should return that attribute's type as string:
  "ID", "IDREF", "IDREFS", "EMFFragmentPath", or nil (meaning CDATA).

  Also, some poor XML documents model references with custom elements, like

    <person>
      <pid>PID</pid>
      <spouse>PID1</spouse>
      <children>PID2 PID3</children>
    </person>

  So here, the pid element's text has the meaning of an ID attribute, the
  spouse element's text has the meaning of an IDREF attribute, and the
  children's text has the meaning of an IDREFS attribute.  To resolve
  references with such documents, you can specify an `text-type-fn` which
  receives 3 arguments: the parent Element's qualified name (see
  `qualified-name`, "person" in the example), the current Element's qualified
  name ("pid", "spouse", or "children" in the example) and the text
  value.  It should return the type of the text as string: "ID", "IDREF",
  "IDREFS", "EMFFragmentPath", or nil (meaning CDATA).

  By default, this function returns a new XML TGraph.  However, you can also
  provide a pre-existing `xml-graph` in which case new elements will be created
  in that instead of a new graph.  That's convenient if you want to put the
  contents of multiple XML files in one single graph.  Of course, then there
  will also be multiple RootElements.
Back to top View Source