xmlanyelement.html
来自「j2ee帮助文档软件设计/软件工程 文件格式」· HTML 代码 · 共 465 行 · 第 1/2 页
HTML
465 行
<xs:element name="a" type="xs:int" /> <xs:element name="b" type="xs:int" /> <xs:any namespace="##other" processContents="lax" /> </xs:choice> </xs:complexType> </xmp></pre> <pre> class Foo { @<A HREF="../../../../javax/xml/bind/annotation/XmlAnyElement.html" title="annotation in javax.xml.bind.annotation"><CODE>XmlAnyElement</CODE></A>(lax="true") @<A HREF="../../../../javax/xml/bind/annotation/XmlElementRefs.html" title="annotation in javax.xml.bind.annotation"><CODE>XmlElementRefs</CODE></A>({ @<A HREF="../../../../javax/xml/bind/annotation/XmlElementRef.html" title="annotation in javax.xml.bind.annotation"><CODE>XmlElementRef</CODE></A>(name="a", type="JAXBElement.class") @<A HREF="../../../../javax/xml/bind/annotation/XmlElementRef.html" title="annotation in javax.xml.bind.annotation"><CODE>XmlElementRef</CODE></A>(name="b", type="JAXBElement.class") }) <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/util/List.html" title="class or interface in java.util"><CODE>List</CODE></A><<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang"><CODE>Object</CODE></A>> others; } @XmlRegistry class ObjectFactory { ... @XmlElementDecl(name = "a", namespace = "", scope = Foo.class) <A HREF="../../../../javax/xml/bind/JAXBElement.html" title="class in javax.xml.bind"><CODE>JAXBElement</CODE></A><Integer> createFooA( Integer i ) { ... } @XmlElementDecl(name = "b", namespace = "", scope = Foo.class) <A HREF="../../../../javax/xml/bind/JAXBElement.html" title="class in javax.xml.bind"><CODE>JAXBElement</CODE></A><Integer> createFooB( Integer i ) { ... } </pre> It can unmarshal instances like <pre><xmp> <foo xmlns:e="extra"> <a>1</a> // this will unmarshal to a <A HREF="../../../../javax/xml/bind/JAXBElement.html" title="class in javax.xml.bind"><CODE>JAXBElement</CODE></A> instance whose value is 1. <e:other /> // this will unmarshal to a DOM <A HREF="http://java.sun.com/j2se/1.5/docs/api/org/w3c/dom/Element.html" title="class or interface in org.w3c.dom"><CODE>Element</CODE></A>. <b>3</b> // this will unmarshal to a <A HREF="../../../../javax/xml/bind/JAXBElement.html" title="class in javax.xml.bind"><CODE>JAXBElement</CODE></A> instance whose value is 1. </foo> </xmp></pre> <h2>W3C XML Schema "lax" wildcard emulation</h2> The lax element of the annotation enables the emulation of the "lax" wildcard semantics. For example, when the Java source code is annotated like this: <pre> @<A HREF="../../../../javax/xml/bind/annotation/XmlRootElement.html" title="annotation in javax.xml.bind.annotation"><CODE>XmlRootElement</CODE></A> class Foo { @XmlAnyElement(lax=true) public <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang"><CODE>Object</CODE></A>[] others; } </pre> then the following document will unmarshal like this: <pre><xmp> <foo> <unknown /> <foo /> </foo> Foo foo = unmarshal(); // 1 for 'unknown', another for 'foo' assert foo.others.length==2; // 'unknown' unmarshals to a DOM element assert foo.others[0] instanceof Element; // because of lax=true, the 'foo' element eagerly // unmarshals to a Foo object. assert foo.others[1] instanceof Foo; </xmp></pre><P><P><DL><DT><B>Since:</B></DT> <DD>JAXB2.0</DD><DT><B>Author:</B></DT> <DD>Kohsuke Kawaguchi</DD></DL><HR><P><!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== --><A NAME="annotation_type_optional_element_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Optional Element Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/xml/bind/annotation/XmlAnyElement.html#lax()">lax</A></B></CODE><BR> Controls the unmarshaller behavior when it sees elements known to the current <A HREF="../../../../javax/xml/bind/JAXBContext.html" title="class in javax.xml.bind"><CODE>JAXBContext</CODE></A>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><? extends <A HREF="../../../../javax/xml/bind/annotation/DomHandler.html" title="interface in javax.xml.bind.annotation">DomHandler</A>></CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/xml/bind/annotation/XmlAnyElement.html#value()">value</A></B></CODE><BR> Specifies the <A HREF="../../../../javax/xml/bind/annotation/DomHandler.html" title="interface in javax.xml.bind.annotation"><CODE>DomHandler</CODE></A> which is responsible for actually converting XML from/to a DOM-like data structure.</TD></TR></TABLE> <P><A NAME="lax()"><!-- --></A><H3>lax</H3><PRE>public abstract boolean <B>lax</B></PRE><DL><DD>Controls the unmarshaller behavior when it sees elements known to the current <A HREF="../../../../javax/xml/bind/JAXBContext.html" title="class in javax.xml.bind"><CODE>JAXBContext</CODE></A>. <h3>When false</h3> <p> If false, all the elements that match the property will be unmarshalled to DOM, and the property will only contain DOM elements. <h3>When true</h3> <p> If true, when an element matches a property marked with <A HREF="../../../../javax/xml/bind/annotation/XmlAnyElement.html" title="annotation in javax.xml.bind.annotation"><CODE>XmlAnyElement</CODE></A> is known to <A HREF="../../../../javax/xml/bind/JAXBContext.html" title="class in javax.xml.bind"><CODE>JAXBContext</CODE></A> (for example, there's a class with <A HREF="../../../../javax/xml/bind/annotation/XmlRootElement.html" title="annotation in javax.xml.bind.annotation"><CODE>XmlRootElement</CODE></A> that has the same tag name, or there's <A HREF="../../../../javax/xml/bind/annotation/XmlElementDecl.html" title="annotation in javax.xml.bind.annotation"><CODE>XmlElementDecl</CODE></A> that has the same tag name), the unmarshaller will eagerly unmarshal this element to the JAXB object, instead of unmarshalling it to DOM. Additionally, if the element is unknown but it has a known xsi:type, the unmarshaller eagerly unmarshals the element to a <A HREF="../../../../javax/xml/bind/JAXBElement.html" title="class in javax.xml.bind"><CODE>JAXBElement</CODE></A>, with the unknown element name and the JAXBElement value is set to an instance of the JAXB mapping of the known xsi:type. <p> As a result, after the unmarshalling, the property can become heterogeneous; it can have both DOM nodes and some JAXB objects at the same time. <p> This can be used to emulate the "lax" wildcard semantics of the W3C XML Schema.<P><DD><DL></DL></DD><DD><DL></DL><DL><DT><B>Default:</B><DD>false</DD></DL></DL><HR><A NAME="value()"><!-- --></A><H3>value</H3><PRE>public abstract <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A><? extends <A HREF="../../../../javax/xml/bind/annotation/DomHandler.html" title="interface in javax.xml.bind.annotation">DomHandler</A>> <B>value</B></PRE><DL><DD>Specifies the <A HREF="../../../../javax/xml/bind/annotation/DomHandler.html" title="interface in javax.xml.bind.annotation"><CODE>DomHandler</CODE></A> which is responsible for actually converting XML from/to a DOM-like data structure.<P><DD><DL></DL></DD><DD><DL></DL><DL><DT><B>Default:</B><DD>javax.xml.bind.annotation.W3CDomHandler.class</DD></DL></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ======= START OF BOTTOM NAVBAR ====== --><A NAME="navbar_bottom"><!-- --></A><A HREF="#skip-navbar_bottom" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../javax/xml/bind/annotation/XmlAnyAttribute.html" title="annotation in javax.xml.bind.annotation"><B>PREV CLASS</B></A> <A HREF="../../../../javax/xml/bind/annotation/XmlAttachmentRef.html" title="annotation in javax.xml.bind.annotation"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?javax/xml/bind/annotation/XmlAnyElement.html" target="_top"><B>FRAMES</B></A> <A HREF="XmlAnyElement.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: REQUIRED | <A HREF="#annotation_type_optional_element_summary">OPTIONAL</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#annotation_type_element_detail">ELEMENT</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_bottom"></A><!-- ======== END OF BOTTOM NAVBAR ======= --><HR><font size="-1"><a href="http://java.sun.com/webapps/bugreport">Submit a bug or feature</a> <p>Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to <a href="../legal/license.html" target="_top">license terms.</a></font></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?