Home / Interview / XML :: General Questions

Interview :: XML

11) How can you apply a DTD to an XML document?

To apply a DTD to an XML document, you can:

  • Use the DTD element definition within the XML document itself.
  • Provide a DTD as a separate file and reference its name in XML document.
12) What are the basic rules to write XML document?

You should consider the following rules to write an XML document.

  • It should have a root element.
  • All tags must be closed.
  • Spaces are not allowed in tag names.
  • All tags must be nested properly.
  • XML tags are case sensitive.
  • Use the attribute values within quotes.
  • Whitespace is preserved in XML.
13)

What is XSL?

XSL stands for Extensible Stylesheet Language. It is a language for expressing stylesheets. These stylesheets are like CSS which describes how to display an XML document of a given type.

14) What is XPath in XML?

XPath is a technology used in XML. It is used to retrieve elements from XML documents. XPath expressions can be used to locate and retrieve elements, attributes and values from XML files because XML documents are structured. It is similar to SQL.

As SQL is used to retrieve data from database, XPath is used to retrieve data from XML.

15) What is XSLT?

XSLT is a popular XML technology which is used to transform one XML file to other format like HTML etc. XSLT is like a language which has its own syntax, functions and operator to transform XML documents. XSLT is also used to display data present in XML files as HTML pages.

16)

What is the difference between XML DTD and XML schema or XSD?

XSL stands for Extensible Stylesheet Language. It is a language for expressing stylesheets. These stylesheets are like CSS which describes how to display an XML document of a given type.

  • DTD stands for Document Type Definition whereas XSD stands for XML Schema Definition.
  • DTD does not support namespaces. It has its own set of keywords to define a schema whereas XSD uses its own set of namespaces and elements to define the schema.
  • DTD is the predecessor of XML schema whereas XML schema is a new technology, some XML parser do not support it yet.

17) Is XML meant to be a replacement of HTML?

No, both languages have their own specification and used for different purposes. XML is used to describes data while HTML focus on how to display data.

18) Define element and attribute in an XML document.

From a start tag to end tag everything you see in a XML document, is XML element. It can contain other elements, attributes and texts.

An Attribute is a value that is used to define additional information about the element.

Let's take an example to understand it well:

In the above example, is an element and id is an attribute of the element.

19) What is the difference between simple element and complex element?

In XML, simple elements are text-based elements. It contains less attributes, child elements, and cannot be left empty.

But, complex elements can hold multiple attributes and elements. It can contain additional sub elements and empty element also.

20) Define the concept of XPOINTER.

XPOINTER is used to point data within XML document. It is used to locate the particular part of the XML document. It is a W3C recommendation.

See this example:

In this example, XPOINTER points "streetnumber = 9" in "address.xml".