Tuesday, December 20, 2005

XML faqs

Interview Questions on XML

Question : Describe the differences between XML and HTML.
Answer : It's amazing how many developers claim to be proficient programming with XML, yet do not understand the basic differences between XML and HTML. Anyone with a fundamental grasp of XML should be able describe some of the main differences outlined in the table below.

Question : Differences Between XML and HTML
Answer :
XML
User definable tags
Content driven
End tags required for well formed documents
Quotes required around attributes values
Slash required in empty tags
HTML
Defined set of tags designed for web display
Format driven
End tags not required
Quotes not required
Slash not required

Question : Describe the role that XSL can play when dynamically generating HTML pages from a relational database.
Answer : Even if candidates have never participated in a project involving this type of architecture, they should recognize it as one of the common uses of XML. Querying a database and then formatting the result set so that it can be validated as an XML document allows developers to translate the data into an HTML table using XSLT rules. Consequently, the format of the resulting HTML table can be modified without changing the database query or application code since the document rendering logic is isolated to the XSLT rules.

Question : Give a few examples of types of applications that can benefit from using XML.
Answer : There are literally thousands of applications that can benefit from XML technologies. The point of this Question is not to have the candidate rattle off a laundry list of projects that they have worked on, but, rather, to allow the candidate to explain the rationale for choosing XML by citing a few real world examples. For instance, one appropriate Answer is that XML allows content management systems to store documents independently of their format, which thereby reduces data redundancy. Another Answer relates to B2B exchanges or supply chain management systems. In these instances, XML provides a mechanism for multiple companies to exchange data according to an agreed upon set of rules. A third common response involves wireless applications that require WML to render data on hand held devices.

Question : What is DOM and how does it relate to XML?
Answer : The Document Object Model (DOM) is an interface specification maintained by the W3C DOM Workgroup that defines an application independent mechanism to access, parse, or update XML data. In simple terms it is a hierarchical model that allows developers to manipulate XML documents easily Any developer that has worked extensively with XML should be able to discuss the concept and use of DOM objects freely. Additionally, it is not unreasonable to expect advanced candidates to thoroughly understand its internal workings and be able to explain how DOM differs from an event-based interface like SAX.

Question : What is SOAP and how does it relate to XML?
Answer : The Simple Object Access Protocol (SOAP) uses XML to define a protocol for the exchange of information in distributed computing environments. SOAP consists of three components: an envelope, a set of encoding rules, and a convention for representing remote procedure calls. Unless experience with SOAP is a direct requirement for the open position, knowing the specifics of the protocol, or how it can be used in conjunction with HTTP, is not as important as identifying it as a natural application of XML.

Question : Can you walk us through the steps necessary to parse XML documents?
Answer : Superficially, this is a fairly basic Question. However, the point is not to determine whether candidates understand the concept of a parser but rather have them walk through the process of parsing XML documents step-by-step. Determining whether a non-validating or validating parser is needed, choosing the appropriate parser, and handling errors are all important aspects to this process that should be included in the candidate's response.

Question : Give some examples of XML DTDs or schemas that you have worked with.
Answer : Although XML does not require data to be validated against a DTD, many of the benefits of using the technology are derived from being able to validate XML documents against business or technical architecture rules. Polling for the list of DTDs that developers have worked with provides insight to their general exposure to the technology. The ideal candidate will have knowledge of several of the commonly used DTDs such as FpML, DocBook, HRML, and RDF, as well as experience designing a custom DTD for a particular project where no standard existed.

Question : Using XSLT, how would you extract a specific attribute from an element in an XML document?
Answer : Successful candidates should recognize this as one of the most basic applications of XSLT. If they are not able to construct a reply similar to the example below, they should at least be able to identify the components necessary for this operation: xsl:template to match the appropriate XML element, xsl:value-of to select the attribute value, and the optional xsl:apply-templates to continue processing the document.

Question : Extract Attributes from XML Data
Answer : Example 1.

Attribute Value:




Question : When constructing an XML DTD, how do you create an external entity reference in an attribute value?
Answer : Every interview session should have at least one trick Question. Although possible when using SGML, XML DTDs don't support defining external entity references in attribute values. It's more important for the candidate to respond to this Question in a logical way than than the candidate know the somewhat obscure Answer.

Question : How would you build a search engine for large volumes of XML data?
Answer : The way candidates Answer this Question may provide insight into their view of XML data. For those who view XML primarily as a way to denote structure for text files, a common Answer is to build a full-text search and handle the data similarly to the way Internet portals handle HTML pages. Others consider XML as a standard way of transferring structured data between disparate systems. These candidates often describe some scheme of importing XML into a relational or object database and relying on the database's engine for searching. Lastly, candidates that have worked with vendors specializing in this area often say that the best way the handle this situation is to use a third party software package optimized for XML data.
Obviously, some important areas of XML technologies were not included in this list -- namespaces, XPointer, XLink, and so on -- and should be added to the interviewer's set of Questions if applicable to the particular position that the candidate is applying for. However, these Questions in conjunction with others to assess soft skills (communication skills, ability to work on teams, leadership ability, etc.) will help determine how well candidates understand the fundamental principles of XML

Question : What is XML?
Answer : XML, the Extensible Markup Language, is a universal syntax for describing and structuring data independent from the application logic. XML can be used to define unlimited languages for specific industries and applications.

Question : Who developed XML?
Answer : XML is an activity of the World Wide Web Consortium (W3C). The XML development effort started in 1996.
A diverse group of markup language experts, from industry to academia, developed a simplified version of SGML (Standard Generalized Markup Language) for the Web. In February 1998, XML 1.0 specification became a recommendation by the W3C.

Question : What are the key benefits of XML?
Answer : XML promises to simplify and lower the cost of data interchange and publishing in a Web environment. XML is a text-based syntax that is readable by both computer and humans. XML offers data portability and reusability across different platforms and devices. It is also flexible and extensible, allowing new tags to be added without breaking an existing document structure. Based on Unicode, XML provides global language support.

Question : What are the applications of XML?
Answer : XML is poised to play a prominent role as a data interchange format in B2B Web applications such as e-commerce, supply-chain management, workflow, and application integration. Another use of XML is for structured information management, including information from databases. XML also supports media-independent publishing, allowing documents to be written once and published in multiple media formats and devices. On the client, XML can be used to create customized views into datAnswer :

Question : What is the relationship between XML and Java technology?
Answer : XML and the Java technology are complementary. Java technology provides the portable, maintainable code to process portable, reusable XML datAnswer : In addition, XML and Java technology have a number of shared features that make them the ideal pair for Web computing, including being industry standards, platform-independence, extensible, reusable, Web-centric, and internationalized.

Question : What are the benefits of using Java technology with XML?
Answer : Java technology offers a substantial productivity boost for software developers compared to programming languages such as C or C++. In addition, developers using the Java platform can create sophisticated programs that are reusable and maintainable compared to programs written with scripting languages. Using XML and Java together, developers can build sophisticated, interoperable Web applications more quickly and at a lower cost.

Question : What XML-related activities is Sun participating in?
Answer : Sun is actively participating in W3C working groups for XML Stylesheet/Transformation Language (XSL/T), XML Schema, Xlink, and XML Query. Sun is also participating in a number of other industry consortia including Oasis, XML.org, and Apache.

Question : What is Java Architecture for XML Binding (JAXB)?
Answer : The Java Architecture for XML Binding (JAXB) simplifies the creation and maintenance of XML-enabled Java applications. JAXB provides a binding compiler and a runtime framework to support a two-way mapping between XML documents and Java objects. The binding compiler translates W3C XML Schema into one or more Java classes without requiring the developer to write complex parsing code. The schema-derived classes and binding framework enable error and validity checking of incoming and outgoing XML documents, thereby making it possible to ensure that only valid, error-free messages are accepted, processed, and generated by a system. For more information, see the Reference Implementation and the Public Draft Specification, both available for download from the JAXB homepage.

Question : What is the difference between JAXB, SAX, and DOM? Which one should I use?
Answer : SAX is an event-driven XML parser that is appropriate for high-speed processing of XML because it does not produce a representation of the data in memory. DOM, on the other hand, produces an in-memory data representation, which allows an application to manipulate the contents in memory. Both SAX and DOM automatically perform structure validation. An application could perform content validation with SAX and DOM, but such an application must provide the necessary extra code, which might be complicated, error-prone, and difficult to maintain.
A JAXB application can perform structure and content validation with Java classes that it generates from a schemAnswer : A JAXB application builds an in-memory data structure, like a DOM, by marshalling an XML document to build a content tree, which contains objects that are instances of the derived classes. However, unlike a DOM tree, a content tree is specific to one source schema, does not contain extra tree-manipulation functionality, allows access to its data with the derived classes' accessor methods, and is not built dynamically. For these reasons, a JAXB application uses memory more efficiently than a DOM application does. If the content of a document is more dynamic and not well-constrained, DOM and SAX are more appropriate than JAXB for processing XML content that does not have a well-known schema prior to processing the content.

Question : How does JAXB work?
Answer : To build a JAXB application, start with an XML schemAnswer : The beta release requires that the schema language be W3C 2001 Recommendation for XML SchemAnswer :
After obtaining an XML Schema, you build and use a JAXB application by performing these steps:
Generate the Java source files by submitting the XML Schema to the binding compiler.
You can use custom binding declarations to override the default binding of XML Schema components to Java representations
Compile the Java source code.
With the classes and the binding framework, write Java applications that:
Build object trees representing XML data that is valid against the XML Schema by either unmarshalling the data from a document or instantiating the classes you created.
Access and modify the datAnswer :
Optionally validate the modifications to the data relative to the constraints expressed in the XML Schema
Marshal the data to new XML documents.

Question : Who is involved in developing JAXB?
Answer : JAXB is being developed through the Java Community Process (JCP) with an expert group consisting of IBM, Software AG, BEA Systems, Hewlett-Packard, TIBCO Software Inc., Oracle, Fujitsu Limited, Breeze Factor LLC, Macromedia, Inc. and Intalio, Inc. Sun is an active member of the W3C XML Schema Working Group and is also working with other industry consortia such as OASIS and xml.org.

Question : What is the Java API for XML Messaging (JAXM)?
Answer : The Java API for XML Messaging (JAXM) is an API designed specifically for the exchange of XML business documents over the Internet. Examples of XML documents that might typically be exchanged are purchase orders, order confirmations, and invoices. You can send non-XML data by adding attachments to your message.

Question : What standards is JAXM based on?
Answer : JAXM is based on the Simple Object Access Protocol (SOAP) 1.1 and SOAP with Attachments specifications. JAXM also allows the implementation of standard protocols on top of the SOAP implementation, such as SOAP-RP or the ebXML Transport, Routing & Packaging V1.0 - Message Service Specification.

Question : Do I have to use the J2EE platform to use JAXM?
Answer : No, you are free to use the Java 2 Platform, Standard Edition (J2SE) as well as the Java 2 Platform, Enterprise Edition (J2EE). A stand-alone client (a client that does not use a messaging provider) can use the J2SE platform to send request-response messages to Web services that process request-response messages. This requires no deployment or configuration from the client, so it is easy to do.

Question : What is a messaging provider?
Answer : A messaging provider is a service that works with the messaging infrastructure to route and transmit messages. What it does is completely transparent to the client sending or receiving a message. An application that uses a messaging provider must use a connection that goes to the provider, called a ProviderConnection object in the JAXM API. Using a messaging provider also requires some deployment and configuration. Normally, a client using a messaging provider runs in a container -- either a servlet or a J2EE container. At deployment time, the client needs to give the container information about the messaging provider. In the future, there will be a deployment tool that makes this easy.

Question : Do I have to use a messaging provider?
Answer : No. You need to use a messaging provider only when your application requires one-way (asynchronous) messaging. In this type of messaging, a message is sent to a recipient as one operation, and the recipient responds at some later time in a different operation. If you application uses a request-response style of messaging, in which the response to a message is sent back as part of the same operation, you do not need a messaging provider. When you do not use a messaging provider, you use a SOAPConnection object, which supports the simpler request-response messaging model.

Question : Can a JAXM message be routed to more than one destination?
Answer : Yes. Intermediate recipients can be specified in a message's header. One way this capability can be used is to automate business processes. For example, two businesses can agree to the conditions under which they exchange XML documents so that they can implement the automatic generation of messages and responses. Assume that two businesses have an arrangement specifying that purchase orders will go first to the order entry department, then to the order confirmation department, then to the shipping department, and finally to the billing department. Each department is an intermediate recipient (called an actor). After an actor has done its part, it removes everything in the header that relates to it and sends the message on to the next actor listed in the header.

Question : Can I use ebXML headers in a JAXM message?
Answer : Yes, you can use ebXML headers if you use an ebXML profile that is implemented on top of SOAP. A profile is a standard protocol, such as ebXML TRP or SOAP-RP, that works on top of SOAP to give you added functionality. You need to use a messaging provider that supports the profile, and you need to arrange with your recipients to use the same profile.

Question : What is the Java API for XML Registries (JAXR)?
Answer : The Java API for XML Registries (JAXR) API provides a uniform and standard Java API for accessing different kinds of XML Registries. XML registries are an enabling infrastructure for building, deployment, and discovery of Web services.

Question : What is the relationship between the JAXR API and other XML APIs?
Answer : Implementations of JAXR providers may use the Jav API for XML-Based RPC (JAX-RPC) for communication between JAXR providers and registry providers that export a SOAP based RPC-like interface (for example, UDDI).
Implementations of JAXR providers may use the Java API for XML Messaging (JAXM) API for communication between JAXR providers and registry providers that export an XML Messaging-based interface (for example, ebXML TRP).
The Java API for XML Processing (JAXP) and Java Architecture for XML Binding (JAXB) may be used by implementers of JAXR providers and JAXR clients for processing XML content that is submitted to or retrieved from the Registry.

Question : Why do we need a new JAXR API when we have the Java Naming and Directory Interface (JNDI)?
Answer : The JNDI API was designed with a very different set of requirements from the JAXR API. Both are abstraction APIs over existing specifications. However, the abstraction in directory services differs considerably from that of XML Registries used for publishing and discovery of Web services. The JAXR API needs richer metadata capabilities for classification and association, as well as richer query capabilities.

Question : Would it not be better to have enhanced the JNDI API with the added functionality of the JAXR API?
Answer : That option was considered. Meeting the additional requirements of XML Registries requires an elaborate information model. The JNDI API has an existing information model that is constrained by design to address the requirements for directory services. Extending the JNDI API would overly constrain the JAXR API and would create backward compatibility issues for the JNDI API.

Question : What is the purpose of Association in the JAXR information model? It is not used anywhere in the API.
Answer : An Association relates two RegistryObjects to each other. An Association may be defined between two objects in the registry and submitted using the GenericLifeCycleManager's saveObjects method.

Question : What is the purpose of Classification in the JAXR information model? It is not used anywhere in the API.
Answer : A Classification classifies a RegistryObject. A Classification may be defined for a RegistryObject and submitted using the GenericLifeCycleManager's saveObjects method.

Question : Why is JAXR an abstraction API and not targeted to a specific registry such as UDDI or ebXML?
Answer : An abstraction-based JAXR API gives developers the ability to write registry client programs that are portable across different target registries. This is consistent with the Java philosophy of Write Once, Run Anywhere. It also enables value-added capabilities beyond what the underlying registries are capable of. For example, a non-JAXR UDDI client does not have the ability to do taxonomy browsing and taxonomy-aware smart queries, which are available to a JAXR client for UDDI.

Question : Why does the JAXR API not use UDDI terms and concepts?
Answer : The JAXR API is not specific to UDDI or any other registry specification. It is an abstraction API that covers multiple specifications. It is designed to enable developer choice in the use of a Web service registry and/or repository. The JAXR API uses UDDI terms and concepts when they fit the JAXR information model (for example, Service, ServiceBinding, and method names in BusinessQueryManager and BusinessLifeCycleManager).

Question : Why did the JAXR information model use the ebXML Registry Information Model as its basis rather than the UDDI data structures?
Answer : The JAXR API is designed to support multiple registries. The ebXML Registry Information Model is more generic and extensible than the UDDI data structures. Because of this characteristic, it was possible to extend the ebXML Registry Information Model to satisfy the needs of UDDI and other registries.

Question : Why was the JAXR information model not designed from the ground up?
Answer : Information models take time to develop. It was easier to start with an existing information model and improve upon it.

Question : What is the Java API for XML-Based RPC (JAX-RPC)?
Answer : The Java API for XML-Based RPC (JAX-RPC) enables Java technology developers to build Web applications and Web services incorporating XML-based RPC functionality according to the SOAP (Simple Object Access Protocol) 1.1 specification.

Question : What is RPC?
Answer : RPC stands for remote procedure call, a mechanism that allows a client to execute procedures on other systems. The RPC mechanism is often used in a distributed client/server model. The server defines a service as a collection of procedures that may be called by remote clients.

Question : How is XML related to RPC?
Answer : The remote procedure call is represented by an XML-based protocol, such as SOAP. In addition to defining envelope structure and encoding rules, the SOAP specification defines a convention for representing remote procedure calls and responses.

Question : What does JAX-RPC have to do with Web services?
Answer : An XML-based RPC server application can define, describe, and export a Web service as an RPC-based service. WSDL (Web Service Description Language) specifies an XML format for describing a service as a set of endpoints operating on messages. With the JAX-RPC API, developers can implement clients and services described by WSDL.

Question : What are the modes of interaction between clients and JAX-RPC services?
Answer : There are three different modes:
Synchronous Request-Response: The client invokes a remote procedure and blocks until it receives a return or an exception.
One-Way RPC: The client invokes a remote procedure but it does not block or wait until it receives a return. The runtime system for the JAX-RPC client may throw an exception.
Non-Blocking RPC Invocation: The client invokes a remote procedure and continues processing in the same thread without waiting for a return. Later, the client processes the remote method return by blocking for the receive or polling for the return.

Question : Can a remote method call or response carry service context information?
Answer : Yes. For example, it may carry a unique transaction identifier or digital signature.

Question : Why doesn't xrpcc generate a WSDL file?
Answer : The xrpcc tool does in fact generate the WSDL file, but due to a bug it gets deleted along with the source files if the -keep option is not specified. You can use the -keep option which will cause xrpcc to not delete the WSDL or .java source files. If you also use the -s sourcepath option, all of the source files will be placed in the sourcepath directory and then you can easily delete them. The WSDL file will still be placed in the current directory or the directory specified by the -d option.

Question : Does the Java 2 Platform, Enterprise Edition (J2EE) use XML?
Answer : The Java 2 Platform, Enterprise Edition (J2EE) promotes the use of XML for data messaging between loosely-coupled business systems. The J2EE reference implementation includes the Java API for XML Parsing (JAXP).
JavaServer Pages (JSP) can generate and consume XML between multi-tier servers or between server and client. Java Message Service (JMS) provides an asynchronous transport mechanism for XML data messaging. Enterprise JavaBeans (EJB) offers a robust, synchronous transport mechanism by allowing a business service object to be invoked by XML tags. EJB also uses XML to describe its deployment properties, such as transactions and security.

Question : Can I generate dynamic XML documents using JSP pages?
Answer : JSP pages enables the authoring of XML pages. XML pages can be generated using JSP pages, which include elements to produce the dynamic portions of the document. The JSP specification includes a powerful tag extension mechanism that can be used to perform XML-based operations, such as applying an XSLT transformation to an XML document.


1. What is XML, and why it is gaining such a momentum?

XML, or Extensible Markup Language, is an excellent way of representing data in a structured format. The most popular application of XML is for data-exchange. Like HTML, XML is also a textual, tag-based "markup" language. However, unlike HTML, which has a fixed set of tags and focuses on "presentation", XML does not have any fixed set of tags, and XML is all about "data". It is possible to create our own tags, and write data inside these tags in an XML document. The XML data is structured in a hierarchical format, and there are many "parsers" available that allow easily getting to the data values.
Some of the reasons behind XML's success include:
The ability to define and use our own tags makes XML "extensible", and self-describing.
XML's textual nature makes it highly portable allowing us to send and receive data from one platform to the other without any issues (such as encoding).
The availability of many free XML parsers and processors, makes it really easy to create, read, and manage XML documents.
As mentioned earlier, XML is all about data. Separating "presentation" from the actual "content" has many benefits, including the flexibility of providing/presenting data to multiple destinations/devices.
The availability of various other standards surrounding the XML (such as XSLT, XPath, and XML Schema); and support for these standards in various toolkits/APIs.
XML is the "standard" backed by W3C and supported by major vendors.
In addition to data-exchange, XML is being used for various other purposes, such as content management, XML-based configuration files, eBusiness, document publishing, application integration, and most notably XML-based messaging or Web services.

2. Take any example, such as Employees, or Customers, and write a sample XML document.





David
Johnson



The above sample XML document illustrates some good practices, such as writing XML declaration line including the encoding attribute; use of namespaces, etc; and also highlights the facts that you know about comments, attributes, etc.

3. What is the difference between well-formed and valid XML document?
W3C, in the XML specification, has defined certain rules that needs to be followed while creating XML documents. The examples of such rules include: having exactly one root element, having end-tag for each start- tag, using single/double quotes for attribute values, and so on. If an XML document follows all these rules, it is said to be well-formed document and XML parsers can be used to parse and process such documents.
Document Type Definitions (DTDs) or XML Schemas can be used to define the structure and content of a specific class of XML documents. This includes the parent-child relationship details, attribute lists, data type information, value restrictions, etc. In addition to the well-formedness rules, if an XML document also follows the rules specified in the associated DTD/Schema, it is said to be a valid XML document. All valid XML documents are well-formed; but the reverse is not always true, that is, well-formed XML documents do not necessarily have to be valid.

4. What is W3C and what is its role in the development of XML family of technologies?
World Wide Web Consortium (W3C), founded by Tim Berners-Lee (inventor of the Web), is a group of less than 100 full-time staff and about 500 members, which includes corporations, government, universities, etc. is an Internet standards body that creates recommendations such as HTML and XML. A very well-defined process is followed to take the idea and turn into a recommendation, which then requires sufficient vendor and developer support to become a successful Web technology.
W3C has divided the Web-related work into five domains (Source: W3C Web site):
Architecture Domain: develops the underlying technologies of the Web, such as URI, DOM, XML, Web Services, etc.
Document Formats Domain: works on formats and languages, such as HTML, CSS, MathML, SVG, etc.
Interaction Domain: to improve user interaction with the Web, and to facilitate single Web authoring to benefit users and content providers alike; includes speech, multimedia, multimodal, etc.
Technology and Society Domain: to develop Web infrastructure to address social, legal, and public policy concerns. Activities include Semantic Web (RDF), Platform for Privacy Preferences (P3P), XML Signature (xmldsig), XML Encryption, XML Key Management, etc.
Web Accessibility Initiative (WAI): to lead the Web to its full potential includes promoting a high degree of usability for people with disabilities, and people not familiar with technologies, etc. This group defines guidelines for browsers, multimedia players, etc.

5. If XML is all about "text" data, is it possible to include binary data (such as an image) in an XML document? If yes, how?
Yes, it is possible to include binary data as part of XML document. The binary data needs to be hex or base64 encoded. Most of the parsers and various XML tools offer the encoding/decoding support for binary data, for example, using Microsoft's XML parser (MSXML), if a node data type is set to bin.base64, the parser automatically does the base64 encoding/decoding.

6. Is it possible to include international character (such as Japanese, or Chinese) characters inside an XML document. If yes, how?
Yes, XML being a Unicode-text-based standard supports international characters. The encoding attribute value in the XML declaration line () needs to be properly set in such cases.

7. What is the use of Namespaces in XML?
As XML does not predefine any set of tags/attribute names. Hence, it is quite possible that two totally different XML documents, defined by two totally different people/ companies, use the same tag name/attribute name. If an application needs to use (merge, process, etc.) above two XML documents together, this would cause confusion and we need a way to distinguish deterministically between tags with the same name. XML Namespaces are used for this purpose. Namespaces are defined using URI (Uniform Resource Identifier), and then associated with the element/attribute names. Namespaces are also used to "group" a logically related set of XML vocabulary.

8. Was XML created to replace HTML? Or will XML ever replace HTML?
It is a fact that the problem with HTML is that combines "data" with the "presentation" details, but XML was not necessarily created to replace HTML, rather it was created with a much broader vision a universal format to structured data. HTML is, and will remain, the primary backbone of the Web. However, the benefits of XML will soon be seen in HTML as well, which is evolving as XHTML 1.0 (HTML 4.01 in XML syntax). So, to Answer the Question: No, XML was not created to replace XML and it will not completely replace HTML; however it is being used to update HTML for better Web.

9. What is XHTML?
Is simple words, XHTML, or Extensible HTML, is HTML 4 with XML rules applied to it (each begin tag must have an end tag, attribute values in single/double quotes, etc.). However, the overall vision of XHTML is much more than that. In addition to using XML syntax for HTML, XHTML also encloses specifications such as XHTML Basic (minimal set of modules for devices such as PDAs), XForms (represents the next generation of forms for the Web, and separates presentation, logic, and data), XML Events (provides XML languages with the ability to uniformly integrate event listeners and associated event handlers), etc.

10. Was XML created to replace databases, specifically RDBMS? Or will XML ever replace databases?
XML and "data" can be assumed to be synonymous, but XML was not created to replace traditional RDBMSs (Relational Database Management Systems), such as SQL Server or Oracle. XML is quite popular for "data-on-move". XML can be used to "contain", "define", and "transform" data, but it is not designed to offer benefits that traditional RDBMS offer, such as security, transaction support, etc. However, for certain applications it would make more sense to "natively" store XML. Instead of using traditional relational databases, Native XML Databases products are available in the market, that can be used to store and manage XML in its native form, for application such as content management, search, etc.

11. Was XML created to replace EDI (Electronic Data Interchange)? Or will XML ever replace EDI?
Considering the complexity, ROI, and various other disadvantages or EDI, think that XML is here to replace EDI (Electronic Data Interchange). We encourage you to read the article XML Set To Change The Face Of E-Commerce.

12. Is it possible to have characters from multiple encodings into a single XML document? If yes, how?
XML declaration line (and hence the encoding attribute) is optional in the XML document. The parser uses the first bytes (Unicode byte-order-mark) in the document to detect if the document is UTF-8 or UTF-16. If document contains characters from encoding other than UTF-8 and UTF-16, it is required to define the encoding attribute with the correct value. Once the encoding is defined for one character set, it is not possible to redefine the encoding or include data from other encoding. However, if it required to represent data from two different encodings, external entities can be used for this purpose.

13. What is XPath?
XML Path Language (XPath) is a W3C specification that defines syntax for addressing parts of XML document. XML document is considered as a logical tree structure, and syntax based on this consideration is used to address elements and attributes at any level in the XML document. For example, considering the XML document described above in Answer to Question 2, /abc:Employees/abc:Emp/@EmpID XPath expression can be used to access the EmpID attribute under the (first) Emp element under the Employees document element. XPath is used in various other specifications such as XSLT.

14. What is XSLT? And what's its use?
XSL Transformations (XSLT) is yet another popular W3C specification that defines XML-based syntax, used to transform XML documents to any other text format, such as HTML, text, XML, etc. XSLT stylesheets can be applied on the source XML document to transform XML into some other XML, or text, HTML, or any other text format.

15. How are DTDs/XML Schemas important while building XML applications?
Document Type Definition (DTD) or XML Schema is used to define the structure and other constrains for the XML documents. If an XML document has an associated DTD/Schema, it is said to be a valid XML document, and it ensures that the XML document structure and data adheres to the predefined rules. While using the XML document in an application, once the XML document is validated, it is then not required to assert/check for parent-child relationship, presence/absence of elements/attributes, data-value range checks, etc. The schema validation already took care of all such issues. If a valid XML document is being used as the media of data transfer between two parties, both can be rest assured that the XML document is as expected. In addition, DTDs/Schemas have many other benefits, including help in understanding the resultant XML document structure/constraints (documentation), and defining DTDs/Schemas is also a good design step.

16. What is DOM?
Document Object Model (DOM) is a W3C specification that defines a standard (abstract) programming API to build, navigate and update XML documents. It is a "tree-structure-based" interface. As per the DOM specification, the XML parsers (such as MSXML or Xerces), load the entire XML document into memory, before it can be processed. XPath is used to navigate randomly in the document, and various DOM methods are used to create and update (add elements, delete elements, add/remove attributes, etc.) the XML documents.

17. What is SAX?
Simple API for XML Processing (SAX) is an alternative to DOM, and can be used to parse XML documents. SAX is based on streaming model. The SAX parser reads input XML stream and generates various parsing events that an application can handle. With each parsing event, the parser sends sufficient information about the node being parsed. Unlike DOM, SAX does not build an in-memory representation of the source XML document, and hence it is an excellent alternative when parsing large XML documents, as SAX does not require that much memory (and resources). Unlike DOM, SAX is not defined/controlled by W3C. See http://www.saxproject.org/ for details.

18. Which is the best API to parse a huge XML document, to get parts of data from the XML document?
If the requirement is to "look-into" a huge XML document for some chunk of data, SAX would be better alternative. DOM load/unload of huge XML documents needs lot of memory and other resources, whereas SAX parses the XML character-by-character, and hence is well suited in this case.

19. Why the XML Web service is such a hot topic in the industry right now? Is it just some hype, or does it have a real value behind it?
Google (Search Web service), Amazon (for Associates, store building), Microsoft (MapPoint.NET), and many other already offer and support XML Web services. Using XML as Internet-based messaging, to integrate applications, is truly a valuable technology that offers a good ROI (considering other integration technologies and interoperability issues) and demands lower integration costs. In last two years, XML Web services received a good momentum, more and more vendors supported it, and surrounding standards were defined to close any lose gaps, making XML Web services quite a mature, low-risk technology , and think will continue in the coming years.

20. What are the core protocols/standards behind XML Web services?
XML (for message format), HTTP and others (for transport), WSDL (Web Service Definition Language, to describe the Web services and define the contract), and UDDI (Universal Description, Discovery and Integration, to dynamically discover and invoke Web services).

0 Comments:

Post a Comment

<< Home