锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
Over the years, the Enterprise Java Technologies Tech Tips have covered a wide variety of enterprise Java technology topics. Here's a short quiz that tests your knowledge of some topics covered in past Tech Tips. You can find the answers at the end of the quiz.
1.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Which of the following inheritance strategies is not supported by the Java Persistence API?
a.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Single Table Per Class Hierarchy
b.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Joined Subclass
c.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Single Table Per Class
d.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Multiple Hierarchy
2.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
What is the primary purpose of the
javax.xml.ws.Provider
API?
a.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Binds XML to Java objects.
b.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Allows web services to work directly with messages.
c.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Simplifies WSDL creation.
d.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Specifies the URL of a web service provider.
e.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
None of the above
3.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Which of the following statements about the
ELResolver
class is true?
a.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
In Java EE 5, the classes
VariableResolver
and
PropertyResolver
have been merged into the
ELResolver
class.
b.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
The way an expression is resolved can be customized by adding custom
ELResolver
subclasses to the
ELResolver
chain.
c.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
To make an
ELResolver
class visible to the Java EE runtime, it must be declared in an application configuration resource file.
d.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
All of the above.
4.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
What does the
<service-name-pattern>
element in the following set of XML statements do:聽
聽聽聽聽聽聽聽聽聽聽聽 <handler-chains xmlns="http://java.sun.com/xml/ns/javaee">
聽聽聽聽聽聽聽聽聽聽聽聽聽聽<handler-chain>\
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <service-name-pattern聽
聽xmlns:ns1="http://example.com/handlers">
聽聽聽聽
聽聽聽聽聽聽聽聽聽聽 ns1:HelloService聽
聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 </service-name-pattern>
聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <handler/>
聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <handler/>
聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 </handler-chain>
聽聽聽聽聽聽聽聽聽聽聽聽聽 </handler-chains>
聽聽聽聽
a.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Applies the handlers specified in the
<handler-chain>
element to the service with the Java EE qname
{http://example.com/handlers}HelloService
.
b.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Adds a service named
HelloService
to the handlers specified in the
<handler-chain>
element.
c.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Applies the handlers specified in the
<handler-chain>
element to all ports whose names begin with
HelloService
.
d.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
None of the above.
5.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
What role does an
XMLHttpRequest
object play in an AJAX-enabled application?
a.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
It's used as a proxy to transmit requests to a server in a different domain.
b.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
It's used to identify a filter for exchange of XML-based
c.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
It's used to transmit
d.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
There is no such thing as an
XMLHttpRequest
object.
Answers
1.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Which of the following inheritance strategies is not supported by the Java Persistence API?
d.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Multiple Hierarchy. The Java Persistence API allows for three different inheritance strategies that dictate how subclasses are mapped to database tables. The three strategies are single table per class hierarchy, joined subclass, and single table per class.聽
2.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
What is the primary purpose of the
javax.xml.ws.Provider
API?
b.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Allows web services to work directly with messages. The JAX-WS 2.0 specification provides two new APIs which make it possible for web services to work with messages or message payloads. The APIs are
javax.xml.ws.Provider
and
java.xml.ws.Dispatch
.
Provider
is a server-side API, while
Dispatch
is a client-side API.聽
3.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
Which of the following statements about the
ELResolver
class is true?
d.聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
All of the above. For more about the
ELResolver
class, especially how to create a customized
ELResolver
.
4. What does the
<service-name-pattern>
element in the following set of XML statements do:聽
聽聽聽聽聽聽聽聽聽聽聽 <handler-chains xmlns="http://java.sun.com/xml/ns/javaee">
聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽<handler-chain>
聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <service-name-pattern聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽xmlns:ns1="http://example.com/handlers">聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ns1:HelloService
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 </service-name-pattern>聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <handler/>聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <handler/>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 </handler-chain>
聽聽聽聽聽聽聽聽聽聽 </handler-chains>
聽聽聽聽e.聽聽聽聽聽聽 Applies the handlers in the specified in the <handler-chain>
element to the service with the Java EE qname {http://example.com/handlers}HelloService
. The <service-name-pattern>
element applies handlers to specific services. Handlers are interceptors that can be easily plugged into the JAX-WS 2.0 runtime environment to do additional processing of inbound and outbound messages. A handler chain is an ordered list of handlers that is used for configuring handlers. .
5.What role does an
XMLHttpRequest
object play in an AJAX-enabled application?
聽 c.聽聽聽聽聽
It's used to transmit
XMLHttpRequest
object plays a central role in the
Steps for DOM Parsing
1. Tell the system which parser you will use
2. Create a JAXP document builder
3. Invoke the parser to create a Document representing an XML
document
4. Normalize the tree
5. Obtain the root node of the tree
6. Examine and modify properties of the node
3).
Steps for SAX Parsing
1. Tell the system which parser you want to use
2. Create a parser instance
3. Create a content handler to respond to parsing events
4. Invoke the parser with the designated content handler and
document
'/>'
.
<?xml version="1.0"?>
聽聽 <
xsl:stylesheet
version="1.0"
聽聽聽聽聽聽聽聽聽聽聽 xmlns:xsl="http://www.w3.org/1999/
XSL/Transform">
<
/xsl:stylesheet
>
4). Using XSLT, how would you extract a specfic attribute from an element in an XML document?
Ans: Extract attributes from XML data
聽聽 <xsl:template match="element-name">
聽聽聽聽 Attribute Value:
聽聽聽聽聽聽聽 <xsl:value-of select="@attribute" />
聽聽聽聽聽聽聽聽 <xsl:apply-templates/>
聽聽聽 </xsl:template>
5). Templates--Controls which output is created from which input
--"
xsl:template
element form
--"
match
attribute contains an Xpath expression (Xpath expression identifies input node set it matches)
--"
For each node in the node set, the
template contents
(things between xsl:template tags) are instantiated and inserted into the output tree.
6). Attributes
In the DTD, XML element attributes are declared with an ATTLIST declaration. An attribute declaration has the following syntax:
<!ATTLIST element-name attribute-name attribute-type default-value> |
The attribute-type can have the following values:
Value | Explanation |
---|---|
CDATA | The value is character data |
(eval|eval|..) | The value must be an enumerated value |
ID | The value is an unique id |
IDREF | The value is the id of another element |
IDREFS | The value is a list of other ids |
NMTOKEN | The value is a valid XML name |
NMTOKENS | The value is a list of valid XML names |
ENTITY | The value is an entity |
ENTITIES | The value is a list of entities |
NOTATION | The value is a name of a notation |
xml: | The value is predefined |
The attribute-default-value can have the following values:
Value | Explanation |
---|---|
#DEFAULT value | The attribute has a default value |
#REQUIRED | The attribute value must be included in the element |
#IMPLIED | The attribute does not have to be included |
#FIXED value | The attribute value is fixed |
DTD example: <!ELEMENT square EMPTY> <!ATTLIST square width CDATA "0"> XML example: <square width="100"></square> |
Syntax: <!ATTLIST element-name attribute-name CDATA "default-value"> DTD example: <!ATTLIST payment type CDATA "check"> XML example: <payment type="check"> |
Syntax: <!ATTLIST element-name attribute-name attribute-type #IMPLIED> DTD example: <!ATTLIST contact fax CDATA #IMPLIED> XML example: <contact fax="555-667788"> |
Syntax: <!ATTLIST element-name attribute_name attribute-type #REQUIRED> DTD example: <!ATTLIST person number CDATA #REQUIRED> XML example: <person number="5677"> |
Syntax: <!ATTLIST element-name attribute-name attribute-type #FIXED "value"> DTD example: <!ATTLIST sender company CDATA #FIXED "Microsoft"> XML example: <sender company="Microsoft"> |
Syntax: <!ATTLIST element-name attribute-name (eval|eval|..) default-value> DTD example: <!ATTLIST payment type (check|cash) "cash"> XML example: <payment type="check"> or <payment type="cash"> |