Skip to content

XPath prequel for Edirom Summer School #2

Open
@tuurma

Description

@tuurma

Basic knowledge of XPath is essential for TEI Publisher customisation.

This short introduction is intended to help understand expressions used through the TEI Publisher on-line course.

XML as a tree

<?xml version="1.0" encoding="UTF-8"?>
<div xmlns="http://my.fantasy.namespace">
    <!-- This whole document is in a made-up namespace -->
    <p>The story begins as two ducks (<name type="org" key="mallards">Mr. and Mrs. Mallard</name>)
        fly over various potential locations in <name type="place" key="new-england">New
            England</name> to start a family.</p>
</div>

mallards (2)

Node types in XML document

  • element
  • attribute
  • text
  • namespace
  • processing-instruction
  • comment
  • document node

Family relationships between nodes

  • parent
  • child
  • ancestor
  • descendant
  • sibling
  • self

child

image

parent

image

descendant

image

ancestor

image

XPath

XPath is a language for selecting sets of nodes

Main thing an XPath expression does is to describe, in a formal way that a computer can process easily, certain sets of nodes, e.g.:

  • title of the document
  • all first paragraphs in a section
  • all references to a name of a person
  • all sections that are not of type appendix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions