Hier ist der folgende Code aus dem Frühjahr-ws Handbuch exzerpiert:JDOM 2 und XPath
public class HolidayEndpoint {
private static final String NAMESPACE_URI = "http://mycompany.com/hr/schemas";
private XPath startDateExpression;
private XPath endDateExpression;
private XPath nameExpression;
private HumanResourceService humanResourceService;
@Autowired
public HolidayEndpoint(HumanResourceService humanResourceService) (2)
throws JDOMException {
this.humanResourceService = humanResourceService;
Namespace namespace = Namespace.getNamespace("hr", NAMESPACE_URI);
startDateExpression = XPath.newInstance("//hr:StartDate");
startDateExpression.addNamespace(namespace);
endDateExpression = XPath.newInstance("//hr:EndDate");
endDateExpression.addNamespace(namespace);
nameExpression = XPath.newInstance("concat(//hr:FirstName,' ',//hr:LastName)");
nameExpression.addNamespace(namespace);
}
Mein Problem ist, dass diese mit JDOM 1.0 zu sein scheinen, und ich mag JDOM 2.0 verwenden.
Wie konvertiere ich diesen Code von JDOM 1.0 zu JDOM 2.0? Warum hat der Frühling seinen Beispielcode nicht aktualisiert?
Danke!
Haben Sie Ihre Importe aktualisiert jDom2 zu benutzen? Der Import für Element ist beispielsweise 'import org.jdom2.Element;'. –