You are on page 1of 5

UNIT-2

Client Side Scripting Language and XML

1. What is XML? //APR/MAY 2011


 XML stands for EXtensible Markup Language
 XML was designed to carry data, not to display data
 XML tags are not predefined. You must define your own tags
 XML is designed to be self-descriptive

2. What is the Difference Between XML and HTML?


 XML and HTML were designed with different goals:
 XML was designed to transport and store data, with focus on what data is
 HTML was designed to display data, with focus on how data looks
 HTML is about displaying information, while XML is about carrying information.

3. What do you mean by a well-formed XML document?


 All XML Elements Must Have a Closing Tag
 XML Tags are Case Sensitive
 XML Elements Must be Properly Nested
 XML Documents Must Have a Root Element
 XML Attribute Values Must be quoted

4. What is an XML Element?


An XML element is everything from (including) the element's start tag to (including)
the element's end tag. An element can contain other elements, simple text or a mixture of
both. Elements can also have attributes.

5. List the XML Naming Rules. //APR/MAY 2011


XML elements must follow these naming rules:
 Names can contain letters, numbers, and other characters
 Names cannot start with a number or punctuation character
 Names cannot start with the letters xml (or XML, or Xml, etc)
 Names cannot contain spaces
 Any name can be used, no words are reserved.

6. Write shot notes on “The XML DOM”.


The XML DOM defines a standard way for accessing and manipulating XML
documents. The XML DOM views an XML document as a tree-structure.
All elements can be accessed through the DOM tree. Their content (text and
attributes) can be modified or deleted, and new elements can be created. The elements, their
text, and their attributes are all known as nodes.

7. What is Uniform Resource Identifier (URI)?


A Uniform Resource Identifier (URI) is a string of characters which identifies an
Internet Resource.
The most common URI is the Uniform Resource Locator (URL) which identifies an
Internet domain address. Another, not so common type of URI is the Universal Resource
Name (URN).
8. Explain Default Namespaces.
Defining a default namespace for an element saves us from using prefixes in all the
child elements. It has the following syntax:
xmlns="namespaceURI"

9. What is XSLT (XML Stylesheet Language Transformations)


XSLT is the style sheet language for XML files.With XSLT you can transform XML
documents into other formats, like XHTML.

10. Explain: XML DTD (Document Type Definition)


The purpose of a DTD (Document Type Definition) is to define the legal building
blocks of an XML document. A DTD defines the document structure with a list of legal
elements and attributes. With DTD, each of your XML files can carry a description of its
own format with it. DTD can be used to verify that the data you receive, and your own data,
is valid.

11. What is XML Schema?


XML Schema is an XML based alternative to DTD. Unlike DTD, XML Schemas has
support for datatypes, and XML Schema use XML Syntax.

12. Give the syntax for Internal DTD declaration.


If the DTD is declared inside the XML file, it should be wrapped in a DOCTYPE
definition with the following syntax:
<!DOCTYPE root-element [element-declarations]>
Example:

<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>

13. Give the syntax for External DTD declaration.


<!DOCTYPE root-element SYSTEM "filename">
Example:
<!DOCTYPE note SYSTEM "note.dtd">

14. What are the building blocks of XML document?


The building blocks XML documents are:
i. Elements
ii. Attributes
iii. Entities
iv. PCDATA
v. CDATA
15. What is an entity in XML? //NOV/DEC 2011
Some characters have a special meaning in XML, like the less than sign (<) that
defines the start of an XML tag.Entities are expanded when a document is parsed by an XML
parser. The following entities are predefined in XML:

Entity References Character


&lt; <
&gt; >
&amp; &
&quot; "
'

16. What is PCDATA?


PCDATA means parsed character data. PCDATA is text that WILL be parsed by a
parser. The text will be examined by the parser for entities and markup. Tags inside the text
will be treated as markup and entities will be expanded.
However, parsed character data should not contain any &, <, or > characters; these need to be
represented by the &amp; &lt; and &gt; entities, respectively.

17. What is CDATA?


CDATA means character data. CDATA is text that will NOT be parsed by a parser.
Tags inside the text will NOT be treated as markup and entities will not be expanded.

18. What is an XML Element?


In a DTD, elements are declared with an ELEMENT declaration. In a DTD, XML
elements are declared with an element declaration with the following syntax:
<!ELEMENT element-name category>
or
<!ELEMENT element-name (element-content)>
Where
element-name  name of the element
element-content elements with children sequences
category  category of data(PCDATA / CDATA)

19. Give the Attribute declaration in XML DTD.


<!ATTLIST element-name attribute-name attribute-type default-value>
Where,
element-namename of the element
attribute-name name of the attribute
attribute-type  type (PCDATA or CDATA)
default valuemay be value or #REQUIRED or #IMPLIED or #FIXED value

20. Give the different types of attribute declarations. //NOV/DEC 2011


Default value: <!ATTLIST square width CDATA "0">
#REQIURED: <!ATTLIST element-name attribute-name attribute-type #REQUIRED>
#IMPLIED : <!ATTLIST element-name attribute-name attribute-type #IMPLIED>
#FIXED value: <!ATTLIST element-name attribute-name attribute-type #FIXED "value">
Enumerated : <!ATTLIST element-name attribute-name (en1|en2|..) default-value>

21. What is a complex element?


A complex element is an XML element that contains other elements and/or attributes.
There are four kinds of complex elements:
 empty elements
 elements that contain only other elements
 elements that contain only text
 elements that contain both other elements and text
22. What are the types of indicators in XML schema?
 Order indicators:
 All
 Choice
 Sequence
 Occurrence indicators:
 maxOccurs
 minOccurs

23. Write notes on order indicators.


Order indicators are used to define the order of the elements.
All Indicator
The <all> indicator specifies that the child elements can appear in any order, and that
each child element must occur only once.
Choice Indicator
The <choice> indicator specifies that either one child element or another can occur.
Sequence Indicator
The <sequence> indicator specifies that the child elements must appear in a specific
order.

24. Write notes on occurrence Indicators.


Occurrence indicators are used to define how often an element can occur.
(i)maxOccurs Indicator
The <maxOccurs> indicator specifies the maximum number of times an element can
occur
(ii)minOccurs Indicator
The <minOccurs> indicator specifies the minimum number of times an element can
occur.
To allow an element to appear an unlimited number of times, use the
maxOccurs="unbounded" statement

25. What is <xsl:template> element? //NOV/DEC 2010


<xsl:template match="/">
The <xsl:template> element is used to build templates. The match attribute is used to
associate a template with an XML element. The match attribute can also be used to define a
template for the entire XML document. The value of the match attribute is an XPath
expression (i.e. match="/" defines the whole document).
26. What is a JavaScript statement? Give an example
When writing your own scripts it's very useful to know some of the most common JavaScript
statements. With if() you can check conditions, while for() allows you to go through a set of
data and do the same with each piece of data.
Example:
if (something is the case) {
more JavaScript commands
}
for (var i=0;i<5;i++) { alert('i = ' + i); }

27. Explain array creation in Java Script with example


An array is a special variable, which can hold more than one value at a time. If you have a
list of items (a list of car names, for example), storing the cars in single variables could look
like this:
var car1="Saab";
var car2="Volvo";
var car3="BMW";
An array can be created in three ways.
The following code creates an Array object called myCars:
1: Regular:
var myCars=new Array();
myCars[0]="Saab";
myCars[1]="Volvo";
myCars[2]="BMW";
2: Condensed:
var myCars=new Array("Saab","Volvo","BMW");
3: Literal:
var myCars=["Saab","Volvo","BMW"];
.

16 Marks:

1. What is XSLT? Explain its relationships with XSL.


2. How document manipulation is done with XML document object module and explains in
detail the various methods of DOM. //NOV/DEC 2010
3. Describe java script global functions in detail
4. Explain message structure and mapping in XML.
5. What is DTD? Explain it with example. //NOV/DEC 2011
6. Describe in detail about DTD and XML schema.
7. Explain Client side scripting using Java Script and Validations
8. Expalin in detail about Document Object Model (DOM)

You might also like