gpt4 book ai didi

org.eclipse.xsd.util.XSDSchemaLocator类的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 04:35:40 26 4
gpt4 key购买 nike

本文整理了Java中org.eclipse.xsd.util.XSDSchemaLocator类的一些代码示例,展示了XSDSchemaLocator类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XSDSchemaLocator类的具体详情如下:
包路径:org.eclipse.xsd.util.XSDSchemaLocator
类名称:XSDSchemaLocator

XSDSchemaLocator介绍

[英]An adapter interface used by org.eclipse.xsd.XSDSchemaDirective to find referenced schemas. When the schema referenced by a schema directive needs to be determined, the containing org.eclipse.emf.ecore.resource.Resourcewill be org.eclipse.emf.ecore.util.EcoreUtil#getRegisteredAdapter(org.eclipse.emf.ecore.resource.Resource,Object) for an adapter that implements this interface. As such, you can register an adapter factory like this to tailor the algorithm used to locate a schema:

ResourceSet resourceSet = new ResourceSetImpl(); 
resourceSet.getAdapterFactories().add 
(new AdapterFactoryImpl() 
{ 
class SchemaLocator extends AdapterImpl implements XSDSchemaLocator 
{ 
public XSDSchema locateSchema(XSDSchema xsdSchema, String namespaceURI,  String rawSchemaLocationURI, String resolvedSchemaLocation) 
{ 
return null;  // Additional logic... 
} 
public boolean isAdatperForType(Object type) 
{ 
return type == XSDSchemaLocator.class; 
} 
} 
protected SchemaLocator schemaLocator = new SchemaLocator(); 
public boolean isFactoryForType(Object type) 
{ 
return type == XSDSchemaLocator.class; 
} 
public Adapter adaptNew(Notifier target, Object type) 
{ 
return schemaLocator; 
} 
});

[中]org使用的适配器接口。日食xsd。XSDSchemaDirective查找引用的模式。当需要确定模式指令引用的模式时,包含该模式的组织。日食电动势。ecore。资源资源将被组织起来。日食电动势。ecore。util。EcoreUtil#getRegisteredAdapter(org.eclipse.emf.ecore.resource.resource,Object),用于实现此接口的适配器。因此,您可以像这样注册适配器工厂,以定制用于定位模式的算法:

ResourceSet resourceSet = new ResourceSetImpl(); 
resourceSet.getAdapterFactories().add 
(new AdapterFactoryImpl() 
{ 
class SchemaLocator extends AdapterImpl implements XSDSchemaLocator 
{ 
public XSDSchema locateSchema(XSDSchema xsdSchema, String namespaceURI,  String rawSchemaLocationURI, String resolvedSchemaLocation) 
{ 
return null;  // Additional logic... 
} 
public boolean isAdatperForType(Object type) 
{ 
return type == XSDSchemaLocator.class; 
} 
} 
protected SchemaLocator schemaLocator = new SchemaLocator(); 
public boolean isFactoryForType(Object type) 
{ 
return type == XSDSchemaLocator.class; 
} 
public Adapter adaptNew(Notifier target, Object type) 
{ 
return schemaLocator; 
} 
});

代码示例

代码示例来源:origin: geotools/geotools

public XSDSchema locateSchema(
      XSDSchema xsdSchema,
      String namespaceURI,
      String rawSchemaLocationURI,
      String resolvedSchemaLocationURI) {
    for (int i = 0; i < locators.size(); i++) {
      XSDSchemaLocator locator = (XSDSchemaLocator) locators.get(i);
      XSDSchema schema =
          locator.locateSchema(
              xsdSchema,
              namespaceURI,
              rawSchemaLocationURI,
              resolvedSchemaLocationURI);
      if (schema != null) {
        return schema;
      }
    }
    if (LOGGER.isLoggable(Level.FINE)) {
      LOGGER.fine("Could not locate schema for: " + rawSchemaLocationURI + ".");
    }
    return null;
  }
}

代码示例来源:origin: geotools/geotools

XSDSchema schema = locator.locateSchema(null, namespaceURI, schemaLocation, null);

代码示例来源:origin: geotools/geotools

locators.get(j).locateSchema(null, namespace, location, null);
XSDSchema schema = locators.get(i).locateSchema(null, uri, null, null);

代码示例来源:origin: org.geotools/gt2-xml-xsd

public XSDSchema locateSchema(XSDSchema xsdSchema, String namespaceURI,
    String rawSchemaLocationURI, String resolvedSchemaLocationURI) {
    for (int i = 0; i < locators.size(); i++) {
      XSDSchemaLocator locator = (XSDSchemaLocator) locators.get( i );
      XSDSchema schema = 
        locator.locateSchema(xsdSchema, namespaceURI, rawSchemaLocationURI, resolvedSchemaLocationURI);
      if (schema != null) {
        return schema;
      }
    }
    return null;
  }
}

代码示例来源:origin: org.geotools/gt2-xml-core

public XSDSchema locateSchema(XSDSchema xsdSchema, String namespaceURI,
    String rawSchemaLocationURI, String resolvedSchemaLocationURI) {
    for (int i = 0; i < locators.size(); i++) {
      XSDSchemaLocator locator = (XSDSchemaLocator) locators.get(i);
      XSDSchema schema = locator.locateSchema(xsdSchema, namespaceURI,
          rawSchemaLocationURI, resolvedSchemaLocationURI);
      if (schema != null) {
        return schema;
      }
    }
    if (LOGGER.isLoggable(Level.FINE)) {
      LOGGER.fine("Could not locate schema for: " + rawSchemaLocationURI + ".");
    }
    return null;
  }
}

代码示例来源:origin: org.geotools.xsd/gt-core

public XSDSchema locateSchema(XSDSchema xsdSchema, String namespaceURI,
    String rawSchemaLocationURI, String resolvedSchemaLocationURI) {
    for (int i = 0; i < locators.size(); i++) {
      XSDSchemaLocator locator = (XSDSchemaLocator) locators.get(i);
      XSDSchema schema = locator.locateSchema(xsdSchema, namespaceURI,
          rawSchemaLocationURI, resolvedSchemaLocationURI);
      if (schema != null) {
        return schema;
      }
    }
    if (LOGGER.isLoggable(Level.FINE)) {
      LOGGER.fine("Could not locate schema for: " + rawSchemaLocationURI + ".");
    }
    return null;
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.xsd

protected XSDSchema locateSchema(XSDSchema xsdSchema, String namespace, String rawSchemaLocation, String resolvedSchemaLocation)
{
 XSDSchemaLocator xsdSchemaLocator = (XSDSchemaLocator)EcoreUtil.getRegisteredAdapter(xsdSchema.eResource(), XSDSchemaLocator.class);
 return 
  xsdSchemaLocator == null ? 
   null : 
   xsdSchemaLocator.locateSchema(xsdSchema, namespace, rawSchemaLocation, resolvedSchemaLocation);
}

代码示例来源:origin: org.geotools/gt2-xml-xsd

/**
 * Convenience method for creating an instance of the schema for this configuration.
 * 
 * @return The schema for this configuration.
 */
public XSDSchema schema() {
  return getSchemaLocator().locateSchema( null, getNamespaceURI(), null, null );
}

代码示例来源:origin: org.eclipse.xsd/org.eclipse.xsd

protected XSDSchema locateSchema(XSDSchema xsdSchema, String namespace, String rawSchemaLocation, String resolvedSchemaLocation)
{
 XSDSchemaLocator xsdSchemaLocator = (XSDSchemaLocator)EcoreUtil.getRegisteredAdapter(xsdSchema.eResource(), XSDSchemaLocator.class);
 return 
  xsdSchemaLocator == null ? 
   null : 
   xsdSchemaLocator.locateSchema(xsdSchema, namespace, rawSchemaLocation, resolvedSchemaLocation);
}

代码示例来源:origin: org.geotools/gt2-xml-xsd

/**
 * Encodes an object, element name pair.
 * 
 * @param object The object to encode.
 * @param element The name of the element to encode.
 * 
 * @return The object encoded.
 * @throws Exception
 */
protected Document encode( Object object, QName element ) throws Exception {
  Configuration configuration = createConfiguration();
  XSDSchema schema = configuration.getSchemaLocator().locateSchema( 
    null, configuration.getNamespaceURI(), null, null
  );
  
  Encoder encoder = new Encoder( configuration, schema );
  ByteArrayOutputStream output = new ByteArrayOutputStream();
  encoder.write( object, element, output );

  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  dbf.setNamespaceAware( true );
  
  return dbf.newDocumentBuilder().parse( 
    new ByteArrayInputStream( output.toByteArray() )
  );
}

代码示例来源:origin: org.geotools/gt2-xml-xsd

XSDSchema schema = locator.locateSchema(null, namespaceURI, schemaLocation, null);
if(schema != null){
  resolvedSchemas.add(schema);

代码示例来源:origin: org.geotools.xsd/gt-core

XSDSchema schema = locator.locateSchema(null, namespaceURI, schemaLocation, null);

代码示例来源:origin: org.geotools/gt2-xml-core

XSDSchema schema = locator.locateSchema(null, namespaceURI, schemaLocation, null);

代码示例来源:origin: org.geotools/gt2-xml-core

XSDSchema schema = locators[j].locateSchema(null, namespace, location, null);
XSDSchema schema = locators[i].locateSchema(null, uri, null, null);

代码示例来源:origin: org.geotools/gt2-xml-xsd

XSDSchema schema = locators[j].locateSchema(null,
      namespace, location, null);
XSDSchema schema = locators[i].locateSchema(null, uri,
    null, null);

代码示例来源:origin: org.geotools.xsd/gt-core

XSDSchema schema = locators[j].locateSchema(null, namespace, location, null);
XSDSchema schema = locators[i].locateSchema(null, uri, null, null);

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com