xpath - EclipseLink MOXy: Logical operators in XmlPath annotation -


do logical operators work in xmlpath annotations of eclipselink moxy? tried , not make work (no exception thrown , nothing bound "elements").

for example, have in bindings file this:

    <java-type name="content">         <java-attributes>            <xml-element java-attribute="elements" xml-path="/a/b/ | /c/d"              type="elementtype" container-type="java.util.list" />         </java-attributes>     </java-type> 

is there way achieve same result modification of bindings without using logical or in xml-path?

i can think of workaround 1 use getters , settings in domain model, bind both /a/b , /c/d elements , have setters append elements list rather replacing list upon each call setelements(). i'd rather handle in bindings file, though.

does there exist place in documentation specifies parts of xpath supported in moxy?

here example of how support use case.

mapping document (bindings.xml)

you use xml-elements mapping use case. on each of nested xml-element mappings specify different xml-path.

<?xml version="1.0"?> <xml-bindings      xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"     package-name="forum17977009">     <java-types>         <java-type name="content">             <xml-root-element/>              <java-attributes>                 <xml-elements java-attribute="elements">                     <xml-element xml-path="a/b"/>                     <xml-element xml-path="c/d"/>                 </xml-elements>              </java-attributes>         </java-type>     </java-types> </xml-bindings> 

java model (content)

below java model use example.

package forum17977009;  import java.util.list;  public class content {      private list<elementtype> elements;      public list<elementtype> getelements() {         return elements;     }      public void setelements(list<elementtype> elements) {         this.elements = elements;     }   } 

jaxb.properties

to specify moxy jaxb provider include file called jaxb.properties in same package domain model following entry (see: http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html).

javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.jaxbcontextfactory 

input (input.xml)

below sample input document.

<?xml version="1.0" encoding="utf-8"?> <content>     <a>         <b/>         <b/>     </a>     <c>         <d/>         <d/>     </c> </content> 

demo

below demo code can run prove works:

package forum17977009;  import java.io.file; import java.util.*; import javax.xml.bind.*; import org.eclipse.persistence.jaxb.jaxbcontextproperties;  public class demo {      public static void main(string[] args) throws exception {         map<string, object> properties = new hashmap<string, object>(1);         properties.put(jaxbcontextproperties.oxm_metadata_source, "forum17977009/bindings.xml");         jaxbcontext jc = jaxbcontext.newinstance(new class[] {content.class}, properties);          unmarshaller unmarshaller = jc.createunmarshaller();         file xml = new file("src/forum17977009/input.xml");         content content = (content) unmarshaller.unmarshal(xml);          marshaller marshaller = jc.createmarshaller();         marshaller.setproperty(marshaller.jaxb_formatted_output, true);         marshaller.marshal(content, system.out);     }  } 

output

since of items of same type, output based on xml-path of first xml-element in xml-elements mapping:

<?xml version="1.0" encoding="utf-8"?> <content>    <a>       <b/>       <b/>       <b/>       <b/>    </a> </content> 

update

does there exist place in documentation specifies parts of xpath supported in moxy?

here examples should help:

we going add validation on xpath statements entered mappings. can track our progress on using following link:


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -