Slides - Book and Byte
Download
Report
Transcript Slides - Book and Byte
Digital Media Technology
Week 8: XSLT 2
□ XSLT more difficult than TEI?
□ A programming language
□ Need to be precise with
respect to syntactic rules
□ Underlying logic of the code
General aims of DMT
□ Develop some affinity with
“coding”
□ Jerome McGann’s notion of
“imagining what we do not know”
□ How should technology be
applied?
□ Use of creativity and building up
confidence
HackaLOD
DMT ‘Hackathon’
□ Seminar next week (15
November)
□ Two sessions will be combined
into one long
□ 7 teams of 3 or 4 students
□ Analyses of XML files using XSLT
and creation of visualisations
Announcements
□ Guest lectures on 22 or 29
November
□ Assignment 2 for DMT will be
posted on 10 November
□ Practical part: an XSLT stylesheet
□ Theoretical questions
Source
Result
Counting elements
<xsl:template match=“collection”>
<xsl:value-of select=
“ count( body/letter ) ”>
</xsl:template>
Counting elements with specific
characteristics
<xsl:template match=“collection”>
<xsl:value-of select=
“ count( body/letter[ language
= ‘English’ ] ) ”>
</xsl:template>
‘Printing’ elements with specific
characteristics
<xsl:template match=“collection”>
<xsl:for-each select=
“body/letter[ year > 1900 ]”>
<xsl:value-of select=“author”/>
</xsl:for-each>
</xsl:template>
Two types of components in
programming languages
1. Statements: instructions which
perform/execute an action. For
example: a calculation or printing
output
2. Flow control: structural
components which determine when
and how statements are executed
Example from PHP
hour = date('h') ;
if ( hour < 12) {
print “Good morning!” ;
} else {
print “Good afternoon!” ;
}
Another example
for ( i = 1 ; i < 10 ; i++ ) {
print i . “ times 5 is ” ;
print i * 5 . “<br/>” ;
}
<xsl:template match=“collection”>
<xsl:for-each select=
“body/letter[ year > 1900 ]”>
<xsl:value-of select=“author”/>
</xsl:for-each>
</xsl:template>
Namespaces
□ Element prefixes which indicate the
‘source’ of each element: which
DTD/Schema does it belong to?
□ Namespace declaration in root
element
□ They help with disambiguation
□ Examples:
xsl:value-of, tei:teiHeader, tei:p,
html:p
Charles Babbage’s Analytic Machine
Artificial Intelligence
□ Alan Turing, “Computing
Machinery and
Intelligence”
□ Turing test
□ The Universal Machine
□ Computer can perform
any activity which can
be caught in an
algorithm (state of being
“Turing-complete”)
Algorithms
□ Term derived from Muhammad AlKhwārizmī, who wrote Al-Kitab almukhtasar fi hisab al-jabr wa'lmuqabala (”The book on
Calculations using the Numbers of
the Indians”)
□ Unambiguous description of the
steps that need to followed to arrive
at a specific result
□ Also see John Searle’s “Chinese
Room Argument”