Introduction
XML is traditionally viewed as a hierarchical tree structure. However, the widespread use of ID and IDREF attributes often transforms these trees into complex directed graphs. Standard query languages like XPath and XQuery are optimized for tree traversal but struggle with graph-specific challenges such as cycles and nodes with multiple parents. GXQuery is a powerful extension to XQuery, introducing the XGraph expression language and topological constraints to handle these complex relationships.
The Graph Nature of XML
In real-world scenarios, data relationships are rarely strictly hierarchical. For instance, a bibliographic database might link papers to multiple authors, and authors to various roles (editor, PC member, etc.) across different venues.
As shown in Figure 1, the bib.xml dataset exhibits a graph structure where nodes can have multiple incoming edges, forming cycles. Standard XQuery lacks the native vocabulary to efficiently query such "loop-back" relationships or to describe spatial and structural relationships between subgraphs. GXQuery fills this gap by treating the XML document as a directed graph rather than a simple hierarchy.
The GXQuery Language
GXQuery bridges the gap between tree-based and graph-based querying through three primary innovations:
- XGraph: This extension of XPath uses variables (e.g.,
%a) as anchors. By referencing the same variable multiple times, a query can explicitly define cycles. The< >syntax allows users to specify exactly which subgraph components should be returned as the result. - Topological Constraints: The language introduces five fundamental operators—
connect,overlap,contain,be contained, anddisjoint—to filter results based on how subgraphs relate to one another structurally. - FLWR Integration: These features are integrated into the standard For-Let-Where-Return (FLWR) framework. GXQuery treats subgraphs as first-class objects (denoted with a
#prefix), allowing for set-like operations on complex structures.
Figure 4 illustrates several query patterns and their results. For example, Query 1 shows a pattern with a cycle, which GXQuery can resolve into specific subgraph results (Results 1, 2, and 3) depending on the data matching.
Implementation and Key Results
The authors demonstrate GXQuery's utility through complex use cases that are difficult or impossible in standard XQuery. These include:
- Cycle Detection: Successfully retrieving a person who published in a conference where they are also a PC member.
- Structural Overlap: Finding conferences that share specific papers with a journal using the
overlapoperator. - Negative Constraints: Using the
disjointoperator to find authors who have not published in specific venues.
To maintain efficiency, the system employs a reachability labeling scheme. This involves contracting strongly connected components into a Directed Acyclic Graph (DAG) and using interval-based labels to determine reachability without traversing the entire graph.
Conclusion and Future Work
GXQuery provides a robust theoretical and architectural framework for querying graph-structured XML. While the current work focuses on language definition and expressive power, future research is directed toward building more sophisticated query optimizers and exploring how the language handles extremely large-scale graphs where subgraph isomorphism becomes computationally expensive.
Summary updated