2012-12-19 3 views
2

일부 XML을 비 정렬 화하여 OGC에서 모든 요소가 최종 객체로 들어 가지 않는 문제가 발생합니다. QueryExpressionTextType 하의 : 여기 JAXB DOM 노드 비 정렬은 요소를 생략합니다

여기를 일으키는 영역

<xsd:complexType name="StoredQueryDescriptionType"> 
    <xsd:sequence> 
     <xsd:element ref="wfs:Title" minOccurs="0" maxOccurs="unbounded"/> 
     <xsd:element ref="wfs:Abstract" minOccurs="0" maxOccurs="unbounded"/> 
     <xsd:element ref="ows:Metadata" minOccurs="0" maxOccurs="unbounded"/> 
     <xsd:element name="Parameter" 
      type="wfs:ParameterExpressionType" 
      minOccurs="0" maxOccurs="unbounded"/> 
     <xsd:element name="QueryExpressionText" 
      type="wfs:QueryExpressionTextType" 
      minOccurs="1" maxOccurs="unbounded"/> 
    </xsd:sequence> 
    <xsd:attribute name="id" type="xsd:anyURI" use="required"/> 
</xsd:complexType> 
<xsd:complexType name="ParameterExpressionType"> 
    <xsd:sequence> 
     <xsd:element ref="wfs:Title" minOccurs="0" maxOccurs="unbounded"/> 
     <xsd:element ref="wfs:Abstract" minOccurs="0" maxOccurs="unbounded"/> 
     <xsd:element ref="ows:Metadata" minOccurs="0" maxOccurs="unbounded"/> 
    </xsd:sequence> 
    <xsd:attribute name="name" type="xsd:string" use="required"/> 
    <xsd:attribute name="type" type="xsd:QName" use="required"/> 
</xsd:complexType> 
<xsd:complexType name="QueryExpressionTextType" mixed="true"> 
    <xsd:choice> 
     <xsd:any namespace="##other" processContents="skip" 
      minOccurs="0" maxOccurs="unbounded"/> 
     <xsd:any namespace="##targetNamespace" processContents="skip" 
      minOccurs="0" maxOccurs="unbounded"/> 
    </xsd:choice> 
    <xsd:attribute name="returnFeatureTypes" 
     type="wfs:ReturnFeatureTypesListType" use="required"/> 
    <xsd:attribute name="language" type="xsd:anyURI" use="required"/> 
    <xsd:attribute name="isPrivate" type="xsd:boolean" default="false"/> 
</xsd:complexType> 
<xsd:simpleType name="ReturnFeatureTypesListType"> 
    <xsd:list itemType="xsd:QName"/> 
</xsd:simpleType> 

어지럽히 것은 XSD 인 부분에 대한 XSD이다 예 XML

<?xml version="1.0"?> 
    <wfs:CreateStoredQuery xmlns:wfs="http://www.opengis.net/wfs/2.0" 
    xmlns:fes="http://www.opengis.org/fes/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:myns="http://www.someserver.com/myns" 
    xsi:schemaLocation="http://www.opengis.net/wfs/2.0 
http://schemas.opengis.net/wfs/2.0/wfs.xsd" 
    service="WFS" version="2.0.0"> 
     <wfs:StoredQueryDefinition id="urn:StoredQueries:FeaturesInPolygon"> 
     <wfs:Title>Features In Polygon</wfs:Title> 
     <wfs:Abstract>Find all the features in a Polygon.</wfs:Abstract> 
     <wfs:Parameter name="AreaOfInterest" type="gml:PolygonType" /> 
     <wfs:QueryExpressionText returnFeatureTypes="myns:Parks" 
      language="urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression" 
      isPrivate="false"> 
      <wfs:Query typeNames="myns:Parks"> 
       <fes:Filter> 
        <fes:Within> 
         <fes:ValueReference>geometry</fes:ValueReference> 
         <gml:Polygon> 
          <gml:exterior> 
           <gml:LinearRing> 
            <gml:posList>0 0 100 0 100 100 0 100 0 0</gml:posList> 
           </gml:LinearRing> 
          </gml:exterior> 
         </gml:Polygon> 
        </fes:Within> 
       </fes:Filter> 
      </wfs:Query> 
     </wfs:QueryExpressionText> 
    </wfs:StoredQueryDefinition> 
</wfs:CreateStoredQuery> 

이다. JAXB는 JAXB 클래스 대신 DOM 객체를 생성하게하는 processContents = "skip"속성을 갖습니다. 나는 JAXB 컨텍스트를 사용하여 나중에 DOM 노드를 언 마샬링 할 것이라고 생각했다. 여기에 내가 시도한 것에 대한 예제 코드가있다.

public static void main(String[] args) throws Exception { 
    InputStream in = new FileInputStream("test/res/createQuery.xml"); 
    JAXBContext context = JAXBContext.newInstance(
      net.opengis.gml.v_3_2_1.ObjectFactory.class, 
      net.opengis.wfs.v_2_0_0.ObjectFactory.class, 
      net.opengis.filter.v_2_0_0.ObjectFactory.class); 
    Unmarshaller unmarshaller = context.createUnmarshaller(); 
    JAXBElement<?> jElem = (JAXBElement<?>) unmarshaller.unmarshal(in); 
    CreateStoredQueryType create = (CreateStoredQueryType) jElem.getValue(); 
    List<StoredQueryDescriptionType> descriptions = create 
      .getStoredQueryDefinition(); 
    StoredQueryDescriptionType desc = descriptions.get(0); 
    List<QueryExpressionTextType> texts = desc.getQueryExpressionText(); 
    QueryExpressionTextType text = texts.get(0); 
    List<Object> contents = text.getContent(); 
    Node node = (Node) contents.get(0); 
    jElem = (JAXBElement<?>) unmarshaller.unmarshal(node); 
    QueryType query = (QueryType) jElem.getValue(); 
    // prints[{http://www.someserver.com/myns}Parks] 
    System.out.println(query.getTypeNames()); 
    // is false 
    System.out.println(query.isSetAbstractSelectionClause()); 
} 

Query 개체를 올바르게 가져옵니다 (typeNames 특성 포함). 그러나 Filter 객체는 건너 뜁니다. Filter 객체는 AbstractSelectionClause를 상속하므로 반환 된 객체에 설정해야하지만 그렇지 않습니다. DOM 요소를 디버깅하고 검사하여 필터가 DOM 트리에 있는지 확인했습니다.

내가 사용하고있는 JAXB 객체를 얻으려면 jvnet OGC project에서 SVN 저장소를 체크 아웃 했으므로 WFS 2.0 스키마를 컴파일해야했지만 Filter와 GML 스키마는 이미 완료되었습니다.

어떤 통찰력이라도 대단히 감사하겠습니다.

답변

1

예제 XML은 81 페이지의 OGC WFS 2.0 사양 문서 (09-025r1)에서 가져온 것입니다. 필터 용 xmlns가 "http://www.opengis.org/fes/2.0"인 오타가 있습니다. is는 "http://www.opengis.net/fes/2.0"이어야합니다. JAXB는 이것을 인식 할 수없는 요소로보고 바닥에 떨어 뜨 렸습니다.