Jump to content

XML-Exam: Some questions


Mufasa

Recommended Posts

Hi everybody,

 

I'm having an XML exam tomorrow and there are still some points which I don't really understand. Appreciate if you could help me understand...

 

 

Ok No. 1) Regarding the attached XML-Document: What is the result following Address?

//md:annotationBody//md:contents[contains(@id, "1")] or //md:annotationBody//md:contents[contains(@id, "2")]

My answer was: delivers each element of md:contents which has a 1 or 2 in its id.

 

But the correct answer is: "true" - because with the 'or' the whole expression becomes a predicate.

 

Can someone please explain this for me? I don't really understand the above explenation.

 

 

No. 2) What is the result of following XQuery?

xquery version "1.0";declare namespace xsi = "...."declare default element namespace "Anootation";element root {   for %V1 in      doc(*./MADCOW.xml*)//textContent[containts(.,"Annotation")]   return      element A         {%V1/../@id}}

The answer is:

	<root xmlns="Annotation">		<A id="1"/>		<A id="2"/>	</root>

But why??

 

 

 

No. 3) Sketch a transformation which returns following information: name of author (author), Title (title) and last content of text (textContent):

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"	xmlns:md="Annotation">	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>	<xsl:template match="/">		<root>		<xsl:apply-templates select="//md:metadata/md:author" />		<xsl:apply-templates select="//md:metadata/title" />		<xsl:apply-templates select="//md:textContent[last()]" />		</root>	</xsl:template>	<xsl:template match="md:author" >		<autor>			<xsl:value-of select="."/>		</autor>	</xsl:template>	<xsl:template match="title" >		<title>			<xsl:value-of select="." />		</title>	</xsl:template>	<xsl:template match="md:textContent" >		<content> 			<xsl:value-of select="." />		</content>	</xsl:template></xsl:stylesheet>

Isn't there a simpler way? I don't really understand what it does in line 8 to 14 :(

 

 

 

I'll add other question when they occur. Thank you in advance for your support.

 

Kind regards

Mufasa

post-170291-0-05112100-1390953497_thumb.jpg

Edited by Mufasa
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...