Thursday, October 25, 2007

Java EJB Interview questions Part2


25. What syntax should be used to describe a more children elements?

For example, if a and b represent child elements:

o a+ -- one or more occurences of a

o a* -- zero or more occurences of a

o a? -- a or nothing

o a, b -- a followed by b

o a | b -- a or b, but not both

o (expression) -- a unit may have more of above expressions

26. What the following tells us in a dtd file?

1.

2.

3.

4.

5.

The first line says that a slideshow element contains one or more slide elements. The second line says that a slide element consists of a title followed by zero or more item elements. The third line says that a title element consists entirely of parsed character data(PCDATA). The "#" sign that precedes PCDATA indicates that what follows is a special word. The fourth line says the item element is either PCDATA or an item. The asterisk at the end says that either one can occur zero or more times in succession. The fifth line says that content is a parameter entity reference.

27. What is mixed-content model?

The content of a tag in the xml file can be #PCDATA or any number of item elements like the fourth line above.

28. Is DTD definition hierarchical?

No. The DTD definition is not hierarchical. But you can work around to make your xml tags hierarchical. For example, if you have a title for slideshow and a title for each slide, you can use slide-title to represent the title in slide and make a definition for slide-title. It is so called "hyphenation hierarchy. Otherwise, the title definition will work for every title in xml file.

29. What is special element value and how to use it?

There are two special values: ANY or EMPTY. The "ANY" notation says that the element may contain any other defined element, or PCDATA. The "EMPTY" notation says that the element contains no contents. For example an empty tag contains no contents.

30. How to reference a DTD file?

If the DTD definition is in a separate file from the XML document, you have to write something to reference it from the XML document. For example, if your slideshow.dtd is ready for use, then, in your xml document file, after the xml declaration, write:





The above statement says that the element slideshow tag will use definition in slideshow.dtd. The SYSTEM identifier specifies the location of the DTD file and the path is relative to the location of the xml document. You may use http:// or file:/ to indicate the path of the DTD file.

Or you can reference a definition within the XML document by using a square brackets like the following, rather than referring to an external DTD file.


...local subset definitions here...

]>

31. How to declare a public DTD?

Replace SYSTEM to PUBLIC and give url to that dtd.


"http://www.somewhere.com/someones/slideshow1.dtd" >

32. What is the meaning of ATTLIST? What do the following statements tell us?

ATTLIST means attribute list. The name that follows ATTLIST specifies the element for which the attributes are being defined. For example, you have a slideshow tag with title, date and author attributes, you may code as:




title CDATA #REQUIRED

date CDATA #IMPLIED

author CDATA "unknown"

>







The DTD tag ATTLIST begins the series of attribute definitions. The slideshow element has three attributes. The title, date and author are the names of attributes of slideshow. CDATA is a type of the attribute; it means unparsed charater data or a text string.

The #REQUIRED means the attribute value must be specified in the document. The #IMPLIED means the value need not be specified in the document.

33. What does the & sign mean in dtd file?

The & sign means an entity variable name. Note it should be ended with semicolon ";" sign. For example:




...

]>



...

©right; ...

Wherever the ©right; is parsed, it will be replaced with entity copyright sign ©.

34. How to declare a parameter entity reference?

Use to declare it and use an & as start and ; as end to enclose the parameter entity reference. For example, TODAY is a parameter entity reference.














]>







HELLO FROM HTML





WELCOME TO THE WILD WORLD



&TODAY;



Save above file as greeting.xml, use your browser to look at it. You may get a similar display, except that the tag will display "NOV 1, 2003". Or you can click here to see the result.

Note: It is possible that your browser may not support XML. If you use MS IE 5.5 above, or NS 5.0 above, you may be able to see it.

0 comments:

Advertisement

 

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