<cars>
<car><make>Cadillac</make><model>Escalade</model><year>2007</year></car>
<car><make>Cadillac</make><model>Escalade</model><year>2011</year></car>
<car><make>Ford</make><model>Mustang</model><year>1968</year></car>
<car><make>Ford</make><model>Mustang</model><year>1998</year></car>
<car><make>Mercedes</make><model>C-Class</model><year>1999</year></car>
<car><make>Mercedes</make><model>C-Class</model><year>2009</year></car>
</cars>
doc("cars.xml")/cars/car[year>2000].data
doc("cars.xml")/cars/car[xs:integer(year) gt 2000]
doc("cars.xml")/cars/car[year gt 2000]
doc("cars.xml")/cars/car[integer(year) > 2000]
<car>
element?<xs:element name="car">
<xs:complexType>
<xs:sequence>
<xs:element name="make" type="xs:string"/>
<xs:element name="model" type="xs:string"/>
<xs:element name="year" type="xs:string"/>
</xs:sequence>
<xs:anyAttribute/>
</xs:complexType>
</xs:element>
<car>
element can be extended with only one attribute<car>
element can be extended with multiple attributes<car>
element cannot have any attributes<car>
element has child elements which can appear in any orderReference: XSD The <anyAttribute>
Element
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>XHTML Example</title></head>
<body bgcolor="#FFFFFF" >
<p>Content goes here ...</p>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>XHTML Example</title></head>
<body name="bodySection">
<p><b>Content goes here ...</b></p>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>XHTML Example</title></head>
<body color="#333333">
<p><i>Content goes here ...</i></p>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>XHTML Example</title></head>
<body id="bodySelection">
<p><strong>Content goes here ...</strong></p>
</body>
</html>
<x/>
Explanation: XML Attributes values must be quoted. Element names are case-sensitive (and CamelCase is one of the naming styles).
<x a="x" a="y"></x>
<p>
#DEFAULT
#OPTIONAL
#IMPLIED
#FIXED
<xsl:with-param>
element defines the value of a parameter to be passed into a template. It can be used within which elements?<xsl:apply-templates>
and <xsl:call-template>
<xsl:param>
and <xsl:processing-instruction>
<xsl:template>
and <xsl:transform>
<xsl:include>
and <xsl:variable>
This question is about understanding the XML аfile contents. XSD is the correct one here - that's the schema document, which describes the XML.
<car>
against a fixed list of values. Which is the correct declaration?<!ATTLIST car color (red|white|blue|black) black>
<!ATTLIST car color (red|white|blue|black) #REQUIRED>
<!ATTLIST car color (red|white|blue|black) #FIXED>
<!ATTLIST car color (red|white|blue|black)>
<!DOCTYPE abc SYSTEM "file/file.dtd">
Explanation: XHTML - Doctypes
xsl:value-of-select="//car/make"/>
. What does it display?<cars>
<car>
<make>Cadillac
<model>Escalade</model>
<price year="2007">$20,000</price>
</make>
</car>
</cars>
<cars>
<car><make>Cadillac</make> <model>Escalade</model> <year>2007</year></car>
<car><make>Ford</make> <model>Mustang</model> <year>1968</year></car>
<car><make>Mercedes</make> <model>C-Class</model> <year>1999</year></car>
</cars>
format-number()
id()
count()
position()
Explanation: count() returns the total number of nodes (3), while position() returns the 0-based index of each node.
<cars>
<car><make>Cadillac</make> <model>Escalade</model ><year>2007</year></car>
<car><make>Cadillac</make> <model>Escalade</model> <year>2011</year></car>
<car><make>Ford</make> <model>Mustang</model> <year>1968</year></car>
<car><make>Ford</make> <model>Mustang</model> <year>1998</year></car>
<car><make>Mercedes</make> <model>C-Class</model> <year>1999</year></car>
<car><make>Mercedes</make> <model>C-Class</model> <year>2009</year></car>
</cars>
<ul>
{
for $x in doc("cars.xml")/cars/car
where $x/year>2000
order by $x/year descending
return <li>{$x}</li>
}
</ul>
<ol>
{
for $x in doc("cars.xml")/cars/car
where $x/year>2000
order by $x/year desc
return <li>{data($x)}</li>
}
</ol>
<ul>
{
for $x in doc("cars.xml")/cars/car
where $x/year>2000
order by $x/year
return <li>{$x}</li>
}
</ul>
<ol>
{
for $x in doc("cars.xml")/cars/car
where $x/year>2000
order by $x/year descending
return <li>{data($x)}</li>
}
</ol>
readyState
property holds the status of the XMLHttpRequest. Which is NOT a valid status?4 (DONE)
3 (LOADING)
1 (PROCESSING)
0 (UNSENT)
<any>
element.<redefine>
element.<xs:extension>
.<cars>
<car><make>Cadillac</make><model>Escalade</model>
<price year="2007">20000</price></car>
<car><make>Ford</make><model>Mustang</model>
<price year="2008">17000</price></car>
<car><make>Mercedes</make><model>C-Class</model>
<price year="2009">24000</price></car>
</cars>
/car[price>20000]/make/model
/car[price>=20000 and @year>=2009]/make/model
//car[price>=20000 and @year>2008]/model
/cars/car[price>=20000 and price[@year>'2008']]/model
NOTE: XPather shows that all answers are incorrect. Report the question.
xs:required
.use
attribute to required
.Reference: XSD Attributres
Mercedes, Cadillac, Ford
?<cars>
<car><make>Cadillac</make><model>Escalade</model>
<price year="2007">20000</price></car>
<car><make>Ford</make><model>Mustang</model>
<price year="2008">17000</price></car>
<car><make>Mercedes</make><model>C-Class</model>
<price year="2009">24000</price></car>
</cars>
<xsl:sort select="make" />
<xsl:sort select="model" />
<xsl:sort select="car" />
<xsl:sort select="price" />
Explanation: A trick question. The <xsl:sort>
will sort the output in ascending (alphabetical for strings) order by default. The select
tells which tag to use for sorting.
select="make"
or select="year"
we get the order Cadillac, Ford, Mercedes
select="price"
we get Ford, Cadillac, Mercedes
select="model"
we get Mercedes, Cadillac, Ford
/* */
<!-- -->
//
(: :)
<xsl:namespace-alias>
element is used to replace a namespace in the style sheet with a different namespace in the output. Which XSLT element needs to be its parent node?<xsl:namespace>
<cars>
<car><make>Cadillac</make><model>Escalade</model><year>2007</year></car>
<car><make>Cadillac</make><model>Escalade</model><year>2011</year></car>
<car><make>Ford</make><model>Mustang</model><year>1968</year></car>
<car><make>Ford</make><model>Mustang</model><year>1998</year></car>
<car><make>Mercedes</make><model>C-Class</model><year>1999</year></car>
<car><make>Mercedes</make><model>C-Class</model><year>2009</year></car>
</cars>
<make>
and <model>
are ancestors of <year>
.<make>
and <model>
are children of <cars>
.<make>
and <model>
are siblings.<car>
and <cars>
are parents of <make>
and <model>
.<cars>
<car><make>Cadillac</make><model>Escalade</model><year>2007</year></car>
<car><make>Ford</make><model>Mustang</model><year>1968</year></car>
<car><make>Mercedes</make><model>C-Class</model><year>1999</year></car>
</cars>
cars {
display: block;
}
car(make),
car(model),
car(year) {
display: inline;
padding-top: 0.5em;
}
car,
cars {
display: block;
}
make,
model,
year {
display: inline;
padding-top: 0.5em;
}
cars {
display: block;
}
car.make,
car.model,
car.year {
display: inline;
padding-top: 0.5em;
}
cars {
display: block;
}
car#make,
car#model,
car#year {
display: inline;
padding-top: 0.5em;
}
<!ELEMENT car (make, model?, year+, price*)>
. What are the rules that need to be followed for each of the elements?<make>
is required, <model>
is optional, <year>
is optional, and <price>
is optional.<make>
is required, <model>
is required, <year>
is optional, and <price>
is optional.<make>
is required, <model>
is required, <year>
is required, and <price>
is optional.<make>
is required, <model>
is optional, <year>
is required, and <price>
is optional.1 <superheroes>
2 <name>Superman</name>
3 <alias>Clark Kent</alias>
4 <birthplace>Krypton</birthplace>
5 <power>Flight</power>
6 <power>X-Ray Vision</power>
7 <power>Super Strength</power>
8 </superheroes>
<birthplace>
<alias>
<name>
<роwer>
Reference best practices for xml attributes
setAttribute()
an example of?<cars>
<car><make>Cadillac</make><model>Escalade</model><year>2007</year></car>
<car><make>Ford</make><model>Mustang</model><year>1968</year></car>
<car><make>Mercedes</make><model>C-Class</model><year>2006</year></car>
</cars>
nextChild
nextSibling
nodeValue
nodename
<document >
´<.msg-1>Hello World!</.msg-1>
</document>