Thanks for your help! It works. Mickael
-----Original Message----- From: Daniel Kulp [mailto:[email protected]] Sent: Thursday, October 11, 2012 10:09 PM To: [email protected]; Mickael Marrache Subject: Re: XPath evaluation of "/schema" results in empty target node On Oct 11, 2012, at 4:07 PM, Mickael Marrache <[email protected]> wrote: > Hi Dan, > > Do I also need to add this prefix in schema.xsd, before every XML element? If > yes, the problem is that this schema is defined as a standard and I can't > modify it. No, just in the bindings file where the xpath is defined. Dan > > Mickael > > -----Original Message----- > From: Daniel Kulp [mailto:[email protected]] > Sent: Thursday, October 11, 2012 10:03 PM > To: [email protected] > Subject: Re: XPath evaluation of "/schema" results in empty target > node > > > You may need to actually prefix it: > > <jxb:bindings version="2.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:jxb="http://java.sun.com/xml/ns/jaxb" > xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" > jxb:extensionBindingPrefixes="xjc" > schemaLocation="schema.xsd" node="/xsd:schema"> > > With XPath expressions, I'm not sure how it would decern if /shema is > referring to the empty prefix or an element with no namespace. > > Dan > > > On Oct 11, 2012, at 3:59 PM, Mickael Marrache <[email protected]> > wrote: > >> Hi, >> >> This is my XML schema (simplified) - schema.xsd: >> >> <?xml version="1.0" encoding="UTF-8"?> <schema >> xmlns:srvcb="com:mycompany:myservice:base" >> xmlns="http://www.w3.org/2001/XMLSchema" >> targetNamespace="com:mycompany:myservice:base" >> elementFormDefault="qualified" xml:lang="EN"> <complexType >> name="MyType" abstract="true"> >> <sequence> >> <element name="a" type="string" /> >> </sequence> >> </complexType> >> </schema> >> >> The plugin declaration in the POM: >> >> <plugin> >> <groupId>org.apache.cxf</groupId> >> <artifactId>cxf-wadl2java-plugin</artifactId> >> <version>${cxf.version}</version> >> <executions> >> <execution> >> <id>generate-sources</id> >> <phase>generate-sources</phase> >> <configuration> >> >> <sourceRoot>${basedir}/target/generated-sources/cxf</sourceRoot> >> <wadlOptions> >> <wadlOption> >> >> <wadl>${basedir}/wadl/mywadl.xml</wadl> >> >> <extraargs> >> >> <extraarg>-b</extraarg> >> >> <extraarg>${basedir}/wadl/bindings.xml</extraarg> >> >> </extraargs> >> >> <packagename>com.mycompany.myservice</packagename> >> </wadlOption> >> </wadlOptions> >> </configuration> >> <goals> >> <goal>wadl2java</goal> >> </goals> >> </execution> >> </executions> >> </plugin> >> >> My bindings file: >> >> <jxb:bindings version="2.1" xmlns="http://www.w3.org/2001/XMLSchema" >> xmlns:jxb="http://java.sun.com/xml/ns/jaxb" >> xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" >> jxb:extensionBindingPrefixes="xjc" schemaLocation="schema.xsd" >> node="/schema"> >> <jxb:globalBindings> >> <xjc:simple /> >> </jxb:globalBindings> >> <jxb:bindings >> >> node="//complexType[@name='MyType']/sequence/element[@name='a']"> >> <jxb:property name="b" /> >> </jxb:bindings> >> </jxb:bindings> >> >> In my WADL, I import the schema as follows: >> >> <?xml version="1.0"?> >> <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >> xsi:schemaLocation="http://wadl.dev.java.net/2009/02 >> http://www.w3.org/Submission/wadl/wadl.xsd" >> xmlns:xsd="http://www.w3.org/2001/XMLSchema" >> xmlns="http://wadl.dev.java.net/2009/02" >> xmlns:srvcb=" com:mycompany:myservice:base"> >> >> <grammars> >> <!-- <include href="schema.xsd" /> --> >> <schema xmlns="http://www.w3.org/2001/XMLSchema" >> xmlns:srvcr="com:mycompany:myservice:rest" >> >> targetNamespace="com:mycompany:myservice:rest"> >> <import >> namespace="com:mycompany:myservice:base" >> schemaLocation="schema.xsd" /> >> </schema> >> </grammars> >> >> ....... >> </application> >> >> When I compile my project, I get the following exception: >> >> Caused by: java.lang.RuntimeException: Error compiling schema from WADL : >> XPath evaluation of "/schema" results in empty target node >> at >> org.apache.cxf.tools.wadlto.jaxrs.SourceGenerator$InnerErrorListener.error(SourceGenerator.java:1534) >> ... 52 more >> Caused by: com.sun.istack.SAXParseException2: XPath evaluation of "/schema" >> results in empty target node >> at >> com.sun.tools.xjc.reader.internalizer.Internalizer.reportError(Internalizer.java:598) >> ... 44 more >> >> >> Thanks in advance, >> Mickael > > -- > Daniel Kulp > [email protected] - http://dankulp.com/blog Talend Community Coder - > http://coders.talend.com > -- Daniel Kulp [email protected] - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com
