EXAM IN SEMI-STRUCTURED DATA Study Code Student Id Family Name First Name

Similar documents
EXAM IN SEMI-STRUCTURED DATA Study Code Student Id Family Name First Name

EXAM IN SEMI-STRUCTURED DATA Study Code Student Id Family Name First Name

EXAM IN SEMI-STRUCTURED DATA Study Code Student Id Family Name First Name

EXAM IN SEMI-STRUCTURED DATA Study Code Student Id Family Name First Name

XML. COSC Dr. Ramon Lawrence. An attribute is a name-value pair declared inside an element. Comments. Page 3. COSC Dr.

XML. Objectives. Duration. Audience. Pre-Requisites

XML. Rodrigo García Carmona Universidad San Pablo-CEU Escuela Politécnica Superior

Exam : Title : XML 1.1 and Related Technologies. Version : DEMO

HTML vs. XML In the case of HTML, browsers have been taught how to ignore invalid HTML such as the <mymadeuptag> element and generally do their best

Knowledge Engineering pt. School of Industrial and Information Engineering. Test 2 24 th July Part II. Family name.

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 27-1

CountryData Technologies for Data Exchange. Introduction to XML

Advanced Studies in IT CT433 Exam Q&A

Automated tools for supporting CC design evidence. September 2008

Part 2: XML and Data Management Chapter 6: Overview of XML

- XML. - DTDs - XML Schema - XSLT. Web Services. - Well-formedness is a REQUIRED check on XML documents

Introduction to XSLT. Version 1.0 July nikos dimitrakas

Excel to XML v3. Compatibility Switch 13 update 1 and higher. Windows or Mac OSX.

Introduction. " Documents have tags giving extra information about sections of the document

Introduction. " Documents have tags giving extra information about sections of the document

XSLT: How Do We Use It?

Delivery Options: Attend face-to-face in the classroom or remote-live attendance.

Excel to XML v4. Version adds two Private Data sets

XML. XML Namespaces, XML Schema, XSLT

Introduction to XML DTD

Delivery Options: Attend face-to-face in the classroom or via remote-live attendance.

7.1 Introduction. extensible Markup Language Developed from SGML A meta-markup language Deficiencies of HTML and SGML

COP 4814 Florida International University Kip Irvine XSLT. Updated: 2/9/2016 Based on Goldberg, Chapter 2. Irvine COP 4814

XML Query Reformulation for XPath, XSLT and XQuery

Author: Irena Holubová Lecturer: Martin Svoboda

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

XSLT (part I) Mario Alviano A.Y. 2017/2018. University of Calabria, Italy 1 / 22

COMP9321 Web Application Engineering

4. Unit: Transforming XML with XSLT

EMERGING TECHNOLOGIES. XML Documents and Schemas for XML documents

Copyright 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 7 XML

XML Applications. Prof. Andrea Omicini DEIS, Ingegneria Due Alma Mater Studiorum, Università di Bologna a Cesena

XSLT program. XSLT elements. XSLT example. An XSLT program is an XML document containing

~ Ian Hunneybell: DIA Revision Notes ~

Structured documents

Session [2] Information Modeling with XSD and DTD

The concept of DTD. DTD(Document Type Definition) Why we need DTD

Semi-structured Data 11 - XSLT

Introduction to XSLT. Version 1.3 March nikos dimitrakas

Lars Schmidt-Thieme, Information Systems and Machine Learning Lab (ISMLL), University of Hildesheim, Germany, Course on XML and Semantic Web

WHITE PAPER. Query XML Data Directly from SQL Server Abstract. DilMad Enterprises, Inc. Whitepaper Page 1 of 32

XML and Databases XSLT Stylesheets and Transforms

Generating Web Pages Using XSLT

Data Presentation and Markup Languages

Querying XML Data. Querying XML has two components. Selecting data. Construct output, or transform data

IBM. XML and Related Technologies Dumps Braindumps Real Questions Practice Test dumps free

XML Overview, part 1

MASTER OF SCIENCE THESIS

EXAM XML 1.1 and Related Technologies TYPE: DEMO

Appendix H XML Quick Reference

Gestão e Tratamento de Informação

XSLT. Lecture 38. Robb T. Koether. Mon, Apr 21, Hampden-Sydney College. Robb T. Koether (Hampden-Sydney College) XSLT Mon, Apr 21, / 26

COPYRIGHTED MATERIAL. Contents. Part I: Introduction 1. Chapter 1: What Is XML? 3. Chapter 2: Well-Formed XML 23. Acknowledgments

SDPL : XML Basics 2. SDPL : XML Basics 1. SDPL : XML Basics 4. SDPL : XML Basics 3. SDPL : XML Basics 5

More XML Schemas, XSLT, Intro to PHP. CS174 Chris Pollett Oct 15, 2007.

Information Systems. DTD and XML Schema. Nikolaj Popov

XSLT. Announcements (October 24) XSLT. CPS 116 Introduction to Database Systems. Homework #3 due next Tuesday Project milestone #2 due November 9

Generating Variants Using XSLT Tutorial

XML: Extensible Markup Language

Oracle Application Server 10g Oracle XML Developer s Kit Frequently Asked Questions September, 2005

Extensible Markup Stylesheet Transformation (XSLT)

The main Topics in this lecture are:

COMP9321 Web Application Engineering. Extensible Markup Language (XML)

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Computer Science And Engineering

Introduction to XML. XML: basic elements

Document Parser Interfaces. Tasks of a Parser. 3. XML Processor APIs. Document Parser Interfaces. ESIS Example: Input document

Introduction to Semistructured Data and XML. Overview. How the Web is Today. Based on slides by Dan Suciu University of Washington

XML and Semantic Web Technologies. II. XML / 5. XML Stylesheet Language Transformations (XSLT)

XSL Elements. xsl:copy-of

Chapter 13 XML: Extensible Markup Language

Copyright 2005, by Object Computing, Inc. (OCI). All rights reserved. Database to Web

10.3 Answer: 10.5 Answer:

XML and XSLT. XML and XSLT 10 February

Computer Science E-259

XML and Content Management

XML Extensible Markup Language

References between Mapping Programs in SAP-XI/PI as of Release 7.0 and 7.1

XML Wrap-up. CS 431 March 1, 2006 Carl Lagoze Cornell University

Marker s feedback version

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. M.Sc. in Advanced Computer Science. Date: Tuesday 20 th May 2008.

7.1 Introduction. 7.1 Introduction (continued) - Problem with using SGML: - SGML is a meta-markup language

The Transformation Language XSL

HR-XML Schema Extension Recommendation, 2003 February 26

Presentation. Separating Content and Presentation Cascading Style Sheets (CSS) XML and XSLT

Written Exam XML Winter 2005/06 Prof. Dr. Christian Pape. Written Exam XML

file://c:\documents%20and%20settings\giovani%20r%20librelotto\my%20documents\dout...

TEST AND PILOT. Wim Kok SCOBDO

Week 2: Lecture Notes. DTDs and XML Schemas

XML Origin and Usages

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

XSL Concepts: Conditions and Loops. Robert Kiffe, Senior Web Developer OmniUpdate, Inc.

Style Sheet A. Bellaachia Page: 22

XML: Introduction. !important Declaration... 9:11 #FIXED... 7:5 #IMPLIED... 7:5 #REQUIRED... Directive... 9:11

Transcript of Abel Braaksma's Talk on XSLT Streaming at XML Prague 2014

/home/karl/desktop/case 1/openesb/Case1XSLT/src/Case1.wsdl

Transcription:

EXAM IN SEMI-STRUCTURED DATA 184.705 10. 01. 2017 Study Code Student Id Family Name First Name Working time: 100 minutes. Exercises have to be solved on this exam sheet; Additional slips of paper will not be graded. First, please fill in your name, study code and student number. Please, prepare your student id. Exercise 1: (12) Consider the following xml schema file test.xsd: <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"> <xsd:element name="w"> <xsd:complextype mixed="false"> <xsd:sequence> <xsd:element name="a" type="xsd:boolean" maxoccurs="2"/> <xsd:element name="b" type="xsd:int" minoccurs="0"/> <xsd:element name="c" type="typec" maxoccurs="1"/> </xsd:sequence> </xsd:complextype> </xsd:element> <xsd:complextype name="typec" mixed="true"> <xsd:choice> <xsd:element name="d" type="xsd:boolean"/> <xsd:sequence> <xsd:element name="b" type="xsd:int" maxoccurs="2"/> </xsd:sequence> </xsd:choice> </xsd:complextype> </xsd:schema> Furthermore, consider the eight different xml files, which are listed below. You may assume that each of the following xml files is well-formed. The point is to determine the validity according to test.xsd. Check which of the following xml files are valid according to test.xsd. 1. <W><A>true</A><B>1</B><C><D>true</D></C></W> valid invalid 2. <A>true</A><B>1</B><C><D>false</D></C> valid invalid 3. <W><A>true</A><C><B>123</B></C></W> valid invalid 4. <W><A/><C><B>123</B></C></W> valid invalid 5. <W><A>false</A><B>12</B><C><B>123</B><B>3</B></C></W> valid invalid 6. <W><A>false</A><B>12</B><B>2</B><C><D>true</D></C></W> valid invalid 7. <W><A>false</A><C><D>true</D><B>34</B></C></W> valid invalid 8. <W><A>false</A><C><D>true</D></C><C><D>false</D></C></W> valid invalid (For every correct answer 1.5 points, for every incorrect answer -1.5 points, for every unanswered question 0 points, you can have at least 0 points on this exercise)

Exercise 2: Decide which of the following statements are true or false. (15) 1. Semi-structured data can be represented as labelled trees. true false 2. XML can be used as programming language and as network protocol. true false 3. DTDs are written in XML syntax. true false 4. A relational table can be represented as an XML document. true false 5. Every XQuery expression can be written as an XPath expression. true false 6. DTDs are more powerful than XML schemas. true false 7. XPath is more powerful than XSLT. true false 8. SAX is a tree-based API for manipulating XML documents. true false 9. Tree-based parsers are faster than event-based parsers. true false 10. Namespaces can be used for disambiguating elements and attributes. true false (For every correct answer 1.5 points, for every incorrect answer -1.5 points, for every unanswered question 0 points, you can have at least 0 points on this exercise)

The following Exercises 3 7 are referring to the XML document report.xml, which can be found on the last page of this exam. Exercise 3: (12) Complete the DTD report.dtd, so that XML documents structured like report.xml (see attachment) are valid according to this DTD. Consider the following points when creating the DTD: report contains exactly one content element, at least one author element, and any number of appendix elements. Authors are stated before the content element while appendices are stated after the content element. The content element has mixed content, sub-elements are authorref, ref, and section. The section element has mixed content, sub-elements are authorref, and ref. The section element has a required attribute title author elements have a sub-element name and a required attribute id with a unique attribute value. ref elements don t have any content, merely a required attribute id which refers to the id of a part element. authorref elements have a required attribute id which refers to the id of a part element. appendix elements have mixed content with sub-elements authorref, ref, a required attribute id with a unique attribute value and a required attribute title. If not specified make reasonable assumptions on the types. File report.dtd: <!ELEMENT report (author+,content,appendix*)> <!ELEMENT content (#PCDATA authorref ref section)*> <!ELEMENT section (#PCDATA authorref ref)*> <!ATTLIST section title CDATA #REQUIRED> <!ELEMENT author (name)> <!ATTLIST author id ID #REQUIRED> <!ELEMENT name (#PCDATA)> <!ELEMENT authorref (#PCDATA)> <!ATTLIST authorref id IDREF #REQUIRED> <!ELEMENT ref EMPTY> <!ATTLIST ref id IDREF #REQUIRED> <!ELEMENT appendix (#PCDATA authorref ref)*> <!ATTLIST appendix id ID #REQUIRED> <!ATTLIST appendix title CDATA #REQUIRED>

Exercise 4: (10) Consider the following XPath queries applied to the document report.xml (see attachement). If the given XPath expression selects the empty node set, write as output empty output If a number is selected as the result (count), write as output this number. Now give the outputs of the respective XPath queries: count(//@id) 9 //appendix[ref]/@id app2 //section[count(authorref)>1]/@title empty output //author[not(@id=//authorref/@id)]/name/text() Trillian count(//content//authorref) 3

Exercise 5: (6) Consider the following XQuery expression xquery.xq: <summary>{ for $s in //section return <section> { if ( count($s/*) < 2 ) then <short /> else <long /> } <title>{$s/@title/string()}</title> { for $a in //author[@id=$s/authorref/@id] return <author>{$a/name/text()}</author> } }</summary> Now give the output of xquery.xq applied to report.xml. You do not need to consider whitespace issues. <summary> <section> <long/> <title>part 1</title> <author>arthur Dent</author> <section> <short/> <title>part 2</title> </summary>

Exercise 6: (12) Create an XSLT-Stylesheet report.xsl, which returns, applied to documents of the form report.xml, a text document being a L A TEX representation of the stored report: For the content element create a \begin{document} and a \end{document} markup. Keep the children of the content elements in the correct order between the begin and end markup. Now, keep all the text as it is, except: Instead of the authorref element output content of the name element of the referred author element. Instead of the ref element output the content of the title attribute of the referred appendix element. Before the contents of a section are printed, output \section{%}, where % is substituted by the value of the title attribute of the section. Hint: To output all contents of mixed elements you have to use: <xsl:apply-templates select="text() *" />. Consider the following output that your XSLT-Stylesheet report.xsl shall return applied to report.xml: \begin{document} This report is co-authored by Arthur Dent and Ford Prefect and organized in two sections. \section{part 1} This section is based on the data collected by Arthur Dent and provided in A. \section{part 2} some text \end{document}

Now write the XSLT-Stylesheet report.xsl. Control structures like xsl:for-each, xsl:if, etc. are not allowed. You do not need to consider whitespace issues. File report.xsl: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="text"/> <xsl:template match="report"> <xsl:apply-templates select="content"/> <xsl:template match="content"> \begin{document} <xsl:apply-templates select="text() *"/> \end{document} <xsl:template match="section"> \section{<xsl:value-of select="@title"/>} <xsl:apply-templates select="text() *"/> <xsl:template match="authorref"> <xsl:variable name="id" select="@id"/> <xsl:apply-templates select="//author[@id=$id]"/> <xsl:template match="author"> <xsl:value-of select="name"/> <xsl:template match="ref"> <xsl:variable name="id" select="@id"/> <xsl:apply-templates select="//appendix[@id=$id]"/> <xsl:template match="appendix"> <xsl:value-of select="@title"/> </xsl:stylesheet>

Exercise 7: (8) Complete the method delauthor, which removes from a document of the form report.xml all author elements which are not referred by an authorref element. The method delauthor has access to a variable doc containing the DOM representation of the XML document and to a variable xpath, which can be used to evaluate xpath expressions over doc. For example, in the specific document report.xml the author element with the attribute id set to author3 has to be removed by the method delauthor. Make sure that your method also works for other documents! You do not need to be concerned with error handling in this task. private static XPath xpath = XPathFactory.newInstance().newXPath(); Document doc; public void delauthor () throws Exception { XPathExpression xpe = xpath.compile("//author[not(@id = //authorref/@id)]"); NodeList list = (NodeList) xpe.evaluate(doc, XPathConstants.NODESET); } for (int i = 0; i < list.getlength(); i++) { Node n = list.item(i); Node p = n.getparentnode(); p.removechild(n); } Total points: 75

You may separate this page! File report.xml: <report> <author id="author1"> <name>arthur Dent</name> </author> <author id="author2"> <name>ford Prefect</name> </author> <author id="author3"> <name>trillian</name> </author> <content> This report is co-authored by <authorref id="author1">a. Dent</authorref> and <authorref id="author2">f. Prefect</authorref> and organized in two sections. <section title="part 1"> This section is based on the data collected by <authorref id="author1">dent</authorref> and provided in <ref id="app1"/>. <section title="part 2"> some text </content> <appendix id="app1" title="a"> some data </appendix> <appendix id="app2" title="b"> even more data extending <ref id="app1"/>. </appendix> </report>