Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XPath prequel for Edirom Summer School #2

Open
tuurma opened this issue Sep 2, 2020 · 2 comments
Open

XPath prequel for Edirom Summer School #2

tuurma opened this issue Sep 2, 2020 · 2 comments

Comments

@tuurma
Copy link
Member

tuurma commented Sep 2, 2020

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
@tuurma
Copy link
Member Author

tuurma commented Sep 2, 2020

TEI/XML document

Viewed in Text mode

teiHeader

Viewed in a Tree Editor

oXygen > Tools > Tree Editor

image

@tuurma
Copy link
Member Author

tuurma commented Sep 2, 2020

Testing XPath expressions

eXide

http://localhost:8080/exist/eXide/index.html

namespace

To query TEI documents, you need to declare the TEI namespace

declare namespace tei="http://www.tei-c.org/ns/1.0";

context

specify the context with doc() or collection() functions, otherwise the entire database is searched

e.g. doc("/db/apps/tei-publisher/data/test/graves6.xml") or collection("/db/apps/tei-publisher/data/test")

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant