2014-04-16 12 views
0

현재 내가 실행하기 위해 다음과 같은 코드를 구현 시간 범위로 이벤트의 부분 검색에 대한 RFC 밖으로 예에 기초 잭 래빗 Libery과 RFC 4791 CalDAV시간 범위별 이벤트의 CalDAV 부분 검색; 네임 스페이스 오류

중 정보를 사용하여 CalDAV를 클라이언트를 구현하려고 ReportMethod

public void test(String strUri, String strXMLFile) { 
    try { 
    Document docXMLRequest = XMLUtilities.loadXMLFile(strXMLFile);   
    ReportInfo repInfo = new ReportInfo(docXMLRequest.getDocumentElement(), DavConstants.DEPTH_INFINITY); 

    ReportMethod repMethod = new ReportMethod(strUri, repInfo); 
    } catch (DavException | IOException e) { 
    e.printStackTrace(); 
    } 
} 

docXMLRequest 에 포함되어 사용 된 XML 내용은 다음과 같다 :

<?xml version="1.0" encoding="utf-8" ?> 
<C:calendar-query xmlns:D="DAV:" 
       xmlns:C="urn:ietf:params:xml:ns:caldav"> 
    <D:prop> 
    <D:getetag/> 
    <C:calendar-data> 
     <C:comp name="VCALENDAR"> 
     <C:prop name="VERSION"/> 
     <C:comp name="VEVENT"> 
      <C:prop name="SUMMARY"/> 
      <C:prop name="UID"/> 
      <C:prop name="DTSTART"/> 
      <C:prop name="DTEND"/> 
      <C:prop name="DURATION"/> 
      <C:prop name="RRULE"/> 
      <C:prop name="RDATE"/> 
      <C:prop name="EXRULE"/> 
      <C:prop name="EXDATE"/> 
      <C:prop name="RECURRENCE-ID"/> 
     </C:comp> 
     <C:comp name="VTIMEZONE"/> 
     </C:comp> 
    </C:calendar-data> 
    </D:prop> 
    <C:filter> 
    <C:comp-filter name="VCALENDAR"> 
     <C:comp-filter name="VEVENT"> 
     <C:time-range start="20060104T000000Z" end="20060105T000000Z"/> 
     </C:comp-filter> 
    </C:comp-filter> 
    </C:filter> 
</C:calendar-query> 

나는 항상 다음과 같은 오류 얻을 서버에 요청 발사하려고 :

Exception in thread "main" org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces. 
    at com.sun.org.apache.xerces.internal.dom.ElementNSImpl.setName(Unknown Source) 
    at com.sun.org.apache.xerces.internal.dom.ElementNSImpl.<init>(Unknown Source) 
    at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.createElementNS(Unknown Source) 
    at org.apache.jackrabbit.webdav.xml.DomUtil.createElement(DomUtil.java:549) 
    at org.apache.jackrabbit.webdav.version.report.ReportInfo.toXml(ReportInfo.java:250) 
    at org.apache.jackrabbit.webdav.client.methods.DavMethodBase.setRequestBody(DavMethodBase.java:204) 
    at org.apache.jackrabbit.webdav.client.methods.ReportMethod.<init>(ReportMethod.java:44) 
    at webDAVStuff.ManageWebDAV.test(ManageWebDAV.java:117) 
    at mainTestRuns.MainTestSyncCalender.main(MainTestSyncCalender.java:24) 

XMLUtilities (관련 방법) :

static public Document loadXMLFile(String strXMLFile) { 
try { 
    Status.printStatusToConsole("Load: "+ strXMLFile); 

    File fileXMLFile = new File(strXMLFile); 
    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); 
    DocumentBuilder dBuilder; 

    dBuilder = dbFactory.newDocumentBuilder(); 
    dbFactory.setNamespaceAware(true); 
    Document docXMLFile = dBuilder.parse(fileXMLFile); 
    docXMLFile.getDocumentElement().normalize(); 

    return docXMLFile; 
} catch (ParserConfigurationException e) { 
    e.printStackTrace(); 
} catch (SAXException e) { 
    e.printStackTrace(); 
} catch (IOException e) { 
    e.printStackTrace(); 
} 

return null; 
} 

누군가가 아이디어를 갖고있을 수 있습니까?

감사합니다.

답변

0

XMLUtilities의 패키지는 어느 패키지입니까? 네임 스페이스 인식 메서드에서 XML 문서를 구문 분석합니까? (setNamespaceAware (true)).

또한 여기에 DavConstants.DEPTH_INFINITY를 사용하지 마십시오. DEPTH_1을 (를) 사용하십시오.

+0

힌트를 보내 주셔서 감사합니다. 질문에 loadXMLFile 메서드를 추가하고 DEPTH_1 상수 - 동일한 오류를 시도했습니다. 도움 주셔서 감사합니다. – Aviation