@Test
  public void testParsingCite100DataFeatures()
      throws ClassCastException, ClassNotFoundException, InstantiationException,
          IllegalAccessException {

    String schemaURL = this.getClass().getResource("../testdata/schema/cite/all.xsd").toString();
    ApplicationSchemaXSDDecoder adapter =
        new ApplicationSchemaXSDDecoder(GMLVersion.GML_2, null, schemaURL);
    FeatureType[] fts = adapter.extractFeatureTypeSchema().getFeatureTypes();
    Assert.assertEquals(19, fts.length);
  }
  @Test
  public void testParsingPhilosopher()
      throws ClassCastException, ClassNotFoundException, InstantiationException,
          IllegalAccessException {

    String schemaURL = this.getClass().getResource("../testdata/schema/Philosopher.xsd").toString();
    ApplicationSchemaXSDDecoder adapter =
        new ApplicationSchemaXSDDecoder(GMLVersion.GML_31, null, schemaURL);
    FeatureType[] fts = adapter.extractFeatureTypeSchema().getFeatureTypes();
    Assert.assertEquals(4, fts.length);
    // TODO do more thorough testing
  }
  // @Test
  public void testParsingXPlanGML20()
      throws ClassCastException, ClassNotFoundException, InstantiationException,
          IllegalAccessException {

    String schemaURL =
        "file:/home/schneider/workspace/lkee_xplanung2/resources/schema/XPlanGML_2_0/XPlanGml.xsd";
    ApplicationSchemaXSDDecoder adapter =
        new ApplicationSchemaXSDDecoder(GMLVersion.GML_31, null, schemaURL);
    FeatureType ft =
        adapter
            .extractFeatureTypeSchema()
            .getFeatureType(new QName("http://www.xplanung.de/xplangml", "BP_Plan"));
    System.out.println(ft);
    // TODO do more thorough testing
  }
  @Test
  public void testParsingCite110SF2()
      throws ClassCastException, ClassNotFoundException, InstantiationException,
          IllegalAccessException {

    String schemaURL =
        this.getClass().getResource("../testdata/schema/cite/cite-gmlsf2.xsd").toString();
    ApplicationSchemaXSDDecoder adapter =
        new ApplicationSchemaXSDDecoder(GMLVersion.GML_31, null, schemaURL);
    FeatureType[] fts = adapter.extractFeatureTypeSchema().getFeatureTypes();
    for (int i = 0; i < fts.length; i++) {
      System.out.println(fts[i]);
    }

    // TODO do more thorough testing
  }
  @Test
  public void testParsingCite110SF1()
      throws ClassCastException, ClassNotFoundException, InstantiationException,
          IllegalAccessException {

    String schemaURL =
        this.getClass().getResource("../testdata/schema/cite/cite-gmlsf1.xsd").toString();
    ApplicationSchemaXSDDecoder adapter =
        new ApplicationSchemaXSDDecoder(GMLVersion.GML_31, null, schemaURL);
    FeatureType[] fts = adapter.extractFeatureTypeSchema().getFeatureTypes();
    Assert.assertEquals(4, fts.length);
    for (FeatureType ft : fts) {
      System.out.println("\nFt: " + ft.getName());
      for (PropertyType pt : ft.getPropertyDeclarations()) {
        System.out.println(pt);
      }
    }
  }
  @Test
  public void testParsingCityGML()
      throws ClassCastException, ClassNotFoundException, InstantiationException,
          IllegalAccessException {

    String schemaURL = "http://schemas.opengis.net/citygml/profiles/base/1.0/CityGML.xsd";
    ApplicationSchemaXSDDecoder adapter =
        new ApplicationSchemaXSDDecoder(GMLVersion.GML_31, null, schemaURL);
    ApplicationSchema schema = adapter.extractFeatureTypeSchema();
    FeatureType[] fts = schema.getFeatureTypes();
    Assert.assertEquals(54, fts.length);

    FeatureType buildingFt =
        schema.getFeatureType(
            QName.valueOf("{http://www.opengis.net/citygml/building/1.0}Building"));
    PropertyType<?> pt =
        buildingFt.getPropertyDeclaration(
            QName.valueOf(
                "{http://www.opengis.net/citygml/1.0}_GenericApplicationPropertyOfCityObject"));
    Assert.assertEquals(8, pt.getSubstitutions().length);
  }
Exemplo n.º 7
0
  private ApplicationSchema buildApplicationSchema(XMLStreamReaderWrapper xmlStream)
      throws XMLParsingException {
    String schemaLocation = xmlStream.getAttributeValue(XSINS, "schemaLocation");
    if (schemaLocation == null) {
      throw new XMLParsingException(
          xmlStream, Messages.getMessage("ERROR_NO_SCHEMA_LOCATION", xmlStream.getSystemId()));
    }

    String[] tokens = schemaLocation.trim().split("\\s+");
    if (tokens.length % 2 != 0) {
      throw new XMLParsingException(
          xmlStream,
          Messages.getMessage("ERROR_SCHEMA_LOCATION_TOKENS_COUNT", xmlStream.getSystemId()));
    }
    String[] schemaUrls = new String[tokens.length / 2];
    for (int i = 0; i < schemaUrls.length; i++) {
      String schemaUrl = tokens[i * 2 + 1];
      try {
        schemaUrls[i] = new URL(new URL(xmlStream.getSystemId()), schemaUrl).toString();
      } catch (MalformedURLException e) {
        throw new XMLParsingException(
            xmlStream, "Error parsing application schema: " + e.getMessage());
      }
    }

    // TODO handle multi-namespace schemas
    ApplicationSchema schema = null;
    try {
      ApplicationSchemaXSDDecoder decoder =
          new ApplicationSchemaXSDDecoder(version, null, schemaUrls);
      schema = decoder.extractFeatureTypeSchema();
    } catch (Exception e) {
      e.printStackTrace();
      throw new XMLParsingException(
          xmlStream, "Error parsing application schema: " + e.getMessage());
    }
    return schema;
  }