Thursday, October 25, 2007

XML Interview Question 4


35. How to declare an image tag in a DTD file?

You can declare an image tag in the following form:

1.

2.
alt CDATA #IMPLIED

src CDATA #REQUIRED

type CDATA "image/gif"

>

3.

4.



The line one declares image as an optional element. The line 2 declares attributes of an image tag. For the moment, you can not declare an image tag like type ("image/gif", "image/jpeg"). The line 3 declares a notation named GIF that stands for the image/gif MIME type. The line 4 creates an external unparsed entity named some to refer to the external image file, image.gif.

36. What is conditional section?

Conditional section is a way to let XML document to choose which dtd should be "included" or "ignored". Use as an end. For example, you want to use a different versions of a DTD for xml document or sgml document, you may code as follows:


... XML-only definitions

]]>


... SGML-only definitions

]]>

... common definitions

37. How many entities are catagorized in dtd?

o Internal entity: An entity that is referenced in its own document content.

o External entity: An entity that is referenced in another file.

o General entity: including internal or external entity

o Parameter entity: An entity that contains DTD specifications that are referenced from within the DTD.

o Parsed entity: An entity that contains XML(text and markup) and is therefore parsed.

o Unparsed entity: An entity that contains binary data(like images)

Return to top

________________________________________

38. What is xmlns?

The xmlns stands for XML NameSpace. It is an attribute for a tag. It is used in DTD to prevent conflicts. For example, the following tells us the title element will use designated DTD.




xmlns CDATA #FIXED "http://www.example.com/slideshow">

...

or

<br /><br /> Overview<br /><br />

or


...>

...



or


...>

...



Overview



...



or


xmlns:xhtml='urn:...'>

...





Here we use "http:", you may use "urn:" instead.

39. What is xsi?

The "xsi" stands for XML Schema Instance like:

xsi:noNamespaceSchemaLocation='YourSchemaDefinition.xsd'

The line specifies the schema to use for elements in the document that do not have a namespace prefix.

40. Where to use XML?

XML can be used in many places:

o Data representation in Web, especially for Java client/server web.

o Data interchange in all sorts of transactions as long as both sides agree on.

o Document-Driven Programming(DDP)

o Binding

o Archiving

41. What is JAXP?

JAXP stands for Java APIs for XML, which let you write your Web application entirely in the Java programming language. There are two broad categories:

o Document-oriented -- processes XML documents using various parsers.

o Procedure-oriented -- including JAX-RPC, JAXM, and JAXR.

42. What is RELAX NG?

RELAX NG stands for Regular Language description for XML. It is simpler than XML structure schema and an emerging standard under the auspices of OASIS. NG stands for Next Generation. For more information on RELAX NG, see www.oasis-open.org/committees/relax-ng/

43. What is XML schema

XML Schema is a large, complex standard that has two parts. One part specifies structure relationships. (This is the largest and most complex part.) The other part specifies mechanisms for validating the content of XML elements by specifying a (potentially very sophisticated) datatype for each element. For more information on XML schema, visit www.w3c.org/XML/Schema

44. What is JAXM?

JAXM stands for Java APIs for XML Messaging. It provides a standard way to send XML documents over the internet form the Java platform. It is based on the SOAP 1.1 and SOAP with Attaqchements specifications which define a basic framework for exchanging XML messages. It can make one-way (asynchronous) messaging, rout of a message to more than one party and guarantee the delivery, whereas the JAX-RPC cannot.

45. How to get a Point-to-Point connection via JAXM?

All JAXM connections are created by using connection factory methods.

SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();

SOAPConnection con = factory.createConnection();

46. How to get a connection to the Messaging Provider via JAXM?

There are two ways to obtain this connection.

ProviderConnectionFactory pcFactory = ProviderConnectionFactory.newInstance();

ProviderConnection pcCon = pcFactory.createConnection();



or



Context ctx = getInitialContext();

ProviderConnectionFactory pcFactory = (ProviderConnectionFactory)ctx.lookup("SomeMsgProvider");

ProviderConnection con = pcFactory.createConnection();

47. How XML is related with other technologies?

There are many XML related technologies directly or non-directly:

o SAX -- Simple API for XML: reads and writes XML data in a server.

o DOM -- Document Object Model: converts an XML document into a collection of objects.

o JDOM -- Java DOM: processes more data-oriented structures.

o dom4j -- DOM for Java: a factory-based implementation, easier to modify for complex, special-purpose apps.

o DTD -- Document Type Definition: specifies the kinds of tags that can be included in XML document.

o Namespace -- writes an XML document that uses two or more sets of XML tags in modular fashion.

o XSL -- Extensible Stylesheet Language: specifies how to identify data, not how to display it.

o XSLT -- Extensible Stylesheet Language for Transformations: specifies what to convert an XML tag into.

o XSL-FO -- Extensible Stylesheet Language for Formatting Objects: specifies how to link multiple areas on a page.

o SAAJ -- SOAP with Attachments API for Java.

o JAXR -- Java API for XML Registries, used to look and find web services.

o TREX -- Tree Regular Expressions for XML, part of RELAX NG

o SOX -- Schema for Object-Oriented XML

o Schematron -- Schema for Object-Oriented XML, an assetion based schema by www.ascc.net.

o ebXML -- Electronic Business with XML developed by UN/CEFACT and OASIS

o cxml -- Commerce XML, more info at www.rosettanet.org

o etc.

48. What is the difference between SAX and DOM?

The Simple API for XML(SAX) and the Document Object Model(DOM) are both defined by the W3C. Unlike a SAX parser, a DOM parser allows random access to particular pieces of data in an XML document. Another difference is that with a SAX parser, you can only read an XML document, but with a DOM parser, you can build an object representation of the document and manipulate it in memory, adding a new element or deleting an existing one.

49. How to transform a DOM tree to an XML document?

Use the following code:

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = factory.newDocumentBuilder();

Document document = builder.parse("xxxList.xml");

Node rootNode = document.getDocumentElement();

NodeList list = document.getElementsByTagName("xxxx");



//add node

Text tnNode = document.createTextNode("yyyy");

newNameNode.appendChild(tnNode);

....



TransformerFactory transFactory = TransformerFactory.newInstance();

Transformer transformer = transFactory.newTransformer();



DOMSource source = new DOMSource(document);



File newXML = new File("newXML.xml");

FileOutputStream os = new FileOutputStream(newXML);

StreamResult result = new StreamResult(os);



transformer.transform(source, result);

0 comments:

Advertisement

 

Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com