How can name conflicts be avoided in XML?
XML allows the user to create their own tags this can lead to conflicts if an attempt is made to mix two different XML documents from different XML applications. In order to avoid this XML uses the concept of namespaces. Which simply uses a prefix to differentiate between two similarly named tags.For Example:
In the above case if both the xml code was to be clubbed together there would be a naming conflict as both the tags of name consists of different content and meaning. In order to avoid this the user simply has to use namespaces.
ie the above code can be re written as:
In this way no conflicts occur.
In XML how can the user create code which contains content that would be ignored by the parser?
Generally an xml parser would parse through all the text in an XML document. When the parser parses through an xml element all the text between the tags is also parsed. The parser has been programmed to do so as a tag may contain more tags inside it. In case the user wants to specify any content that he does not want the parser to parse he can use the property of CDATA. Everything that a user specifies within a cdata section would be ignored by the parser.
The syntax for CDATA section:
<![CDATA[" and ends with "]]>
Some of the restrictions of the cdata section are:
- A cdata section cannot contain the string “]]>”.
- CDATA section nesting is not allowed.
How are documents accessed and manipulated in XML?The XML DOM (document object model) is used the access and management of xml. It is a platform that is language neutral and allows a program or a script to dynamically access a document. It also allows the updation of content as well as the structure and style of the document. It is responsible for the defining of the object and properties of all xml elements as well as to define the methods for their access.
There are various methods that can be used in xml dom such as:
1. getElementsByTagName : Used to call a specific user defined tag.
2. setAttribute : Used to change the value of an existing attribute.
3. appendChild : Used to add a child node to another node.
Write a code for XML news?
The xml news is a specification that is used for the exchange of information and news. An example of an XML news document is as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<hl1>143 Dead in Natural Disaster</hl1>
<bytag>By Bob Roy, News Line Press</bytag>
<date>Monday January 12 2012 9:13 ET</date>
How are white-spaces handled by xml?Any white-space ( this includes line breaks, tab characters and normal spaces etc.) are passed by the xml parser unchanged to an application. This implies that it is not the responsibility of a parser on how to interpret a white-space, instead it is the responsibility of the application to know what to do with it. The white-spaces in xml can be broadly categorized into two types:
1. Insignificant white-space : Those whites-paces that are found between structural elements and are passed by the parser as they are to the application without any effect ( suppressed) are the insignificant spaces. A good example of such white-spaces are the spaces given in an html document.
2. Significant white-space : Those spaces that occur between the elements and can contain text and markup mixed together and are passed by the parse exactly the way they are to the application for their handling are known as the significant white-spaces.
What is E4X in reference to XML?
The E4X is a java script standard that is officially released by them. It extends the direct support of xml in java scripts. It allows the user to declare a xml variable in the same way an array is declared.For Example:
var x = new XML()
document.write(employees.person.(name == "Tove").age);
The E4X on being used by the user greatly reduces the amount of code that has to be written to execute an operation.
How is metadata handled by xml?
The xml does not contain any predefined elements. Xml generally in broad terms is considered to be an architecture and not an application. Due to this reason it is not the responsibility of xml to specify how metadata is to be implemented. It is left up to the user to select how to implement metadata. Most browsers have their own way of specifying a method to handle metadata. The xml metadata interchange is used as a standard way for users to exchange information pertaining to metadata. The metadata information is usually stored in the form of attributes.For Example:
<body>Don't forget me this weekend!</body>
<body>I will not</body>
In the above code the id is used to identify different xml elements, this is also a form of metadata.
While writing an xml document what are the rules that are to be followed?
Since xml does not have any predefined tags or elements there are not much problems in writing an xml document. Although there are a few rules that should be kept in mind while writing the document such as:
- The tags in xml once opened should also must be closed.
- All the tags in xml are case sensitive.
- All xml elements must be properly nested.For Example:
- The entire document must contain a root node which would contain all the tags defined in the document within it.
- Any attribute values must be specified between quotes.
What do you understand by SVG and SMIL? Give examples
The SVG and SMIL are xml languages that are specifically used for multimedia purposes.1. SVG (scalable vector graphics) :
This language enables the user to display 2 dimensional vector graphic images and animations from the xml code. It makes use of the vector mathematical formulas to render the content.2. SMIL (synchronized multimedia integration language) :
This language is used to integrate text , images and other media together for a presentation.For Example : A simple svg example:
<rect x="10" y="10" height="100" width="100"
style="stroke:#ff0000; fill: #0000ff"/>
What is the role of the doctype declaration in reference to XML?The doctype has several purposes in an xml document such as:
1. It is used for validation purposes of the document.
2. It helps the browser to tell which version of the markup language was used by the creator.
3. The doctype helps in rendering a page properly in a browser that is standards compliant.
The doctypes can be differentiated into three major types:
strict doctype declaration : This declaration is used when css is being used to style a page.
transactional doctype declaration : This doctype specification is used if the document consists of any presentational markups.
frames doctype declaration : This is used id the document is present in form of frames.
Explain the used of the xml prolog section.
The xml prolog of a xml document is the beginning of an xml document. It consists of the information about the xml document and can be used by both the users and computers to know about the document. The prolog to an xml schema must contain:XML declaration :
The xml declaration is used to specify the version of xml used to write it and to declare that the document is an xml.For Example:
<?xml version=”1.0” encoding=”UTF-8”?>The xml element or root declaration :
It defined the root element within which all the other xml elements / tags used are contained. In case of schemas it consists of an xmlns ( xml namespace) attribute that is used to define the namespace for the schema.For Example:
<xsd:schema xmlns: xsd=”http://www.abc.org/2001/XMLSchema”>
What is the use of annotations in reference to an xml document?
The annotations are used in a xml document to provide additional information about the xml document. The annotation element can be followed by a documentation element to make it understandable to a user (human). In case an annotation element is followed by an appInfo element then the information is meant to be used by an application.Example of an annotation followed by document element:
This is a collection of best-selling books.
What are the different scenarios under which an xml schema may be used?The xml schema may be used in case the user wants to have the following requirements:
1. The xml schema can be used when the user requires the information to be included in the document is correct and in a consistent format.
2. It can be used when the user has to create a large set of xml documents with all the documents following a common structure.
3. When the document structure is to be shared with other users if an application is built and it follows a particular file structure.
4. Schema in xml are particularly helpful if the xml documents are going to contain a large amount of data. The schema gives the user the flexibility to define the structure according to his requirements.
How can child elements be specified upon using a sequence compositor?
When a sequence compositor is used the child elements can be specified in either of the two ways:ref attribute :
The ref attribute which will contain the value of the attribute which will be equal to the value of the name attribute in every child elements element declaration. This attribute should always refer to an actual element declaration.For Example:
<xsd:complexType>name attribute :
This attribute is used by specifying a value equal to the child elements name and with it the type attribute is specified as well. The type attribute would contain the user defined complex type.For Example:
<xsd:element name=”book” type=”bookType”/>
Write the steps involved in the creation of a custom schema.
The main steps involved in the creation of a schema are as follows:The creation of an XML prolog and schema element :
During this process the user would define the information about the xml document and can contain annotataions for another uer or application to know more about the schema.Adding namespace :
Once the prolog and the schema element is defined the user can define the xmlns attribute to the schema. For Example:
<?xml version=”1.0” encoding=”UTF-8”?>
Addition of all the element and attribute declarations created by the user. A snippet of the declarations is given below:
<xsd:complexType name=”bookType”>Saving the schema :
once the user has entered all the declarations in the file the file can be saved using the .xsd extension.
What are the different formatting objects in XSL-FO are categorized into?The XSL-FO is used to specify how the content of a structured xml document can be displayed. The objects are organized into the following categories:
1. Declaration, pagination & layout : This is used to define the basic layout of the page.
2. Block : When this type of formatting is used it creates paragraphs, block quotes etc.
3. Inline : On using this formatting technique it would create styles such as itlaics , colors and special characters inside a block.
4. Table : This is used for the creation and controlling of tables.
5. List : This type of formatting is used to control the lists of all types.
6. Links and multi : They are used to handle the style links and multimedia components.
7. Out-of-line : This formatting create and style the float areas.
8. Other : This is used as a ctach all for all the objects that dont fit in anywhere else.
What are the types of nodes in the Xpath data model? Explain briefly.There are seven kinds of nodes in the Xpath data model:
1. Root node : This node is the root of the xml document and contains all the elements of the document.
2. Element node : For every element in a document there exists an element node that will in turn contain other elements within it.
3. Attribute node : Every element node has a set of associated attribute nodes.
4. Namespace node : Every element has a namespace node associated to it. Similar to attribute nodes the element nodes are parents to the namepsace nodes.
5. Processing instruction node : For every processing instruction in a document there exists a SOLARISTM Kernel - Solaris Internals and Performance FAQprocessing instructions node.
6. Comment node : For every comment contained in a document there is a comment node unless it is a part of the dtd.
7. Text node : All character data are stored in the text nodes. Every text node in itself contains at least one character.
What are the advantages of using Xforms over HTML?The Xforms is an application that has been created by the abc. The xforms application enables the separation of presentation and content. It also provides the user with expanded form capabilities.
The advantages of using the xforms over html forms are as follows:
1. The data related to the form can be submitted and collected in the form of xml.
2. It allows external xml documents to be loaded as initial form data.
3. The xforms support xpath expressions and can also support xml schema datatypes.
4. This application can be integrated with different web services.
5. The application of xforms is device independent.
6. It also supports / provides a few more additional features such as:
- Capability to specify initial value for form data.
- Switch element for form completion etc.
How can a xml file be created from a database?
To generate an xml database response from a server the user simply has to write the code and save it as an .asp file on the server.The code:
response.ContentType = "text/xml"
sql="select fname,lname from tblGuestBook"
response.write("<?xml version='1.0' encoding='ISO-8859-1'?>")
while (not rs.EOF)
response.write("<fname>" & rs("fname") & "</fname>")
response.write("<lname>" & rs("lname") & "</lname>")
Briefly explain the XML spy 2005 multitool.The xms spy is considered to be one of the best multi tools available around for xml. It knows how to deal with XSLT, XPath, XQuery, WSDL, SOAP etc.
The complete spy suite consists of the following products:
1. XMLSpy : This is a xml editor that allows the user to create, debug, validate and edit xml doucments in standard recognized way.
2. MaprForce : This is a visual data mapping tool that can be used by the user to change the data format from one form to another.
3. StyleVision : This application allows the user to create the XSLT and XSL:FO stylesheets which can be used to transform the xml documents. It can also be used to change the xml document into a HTML or PDF file.