org.eclipse.xsd.XSDSchema.getSchemaLocation()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(116)

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

XSDSchema.getSchemaLocation介绍

[英]Returns the value of the 'Schema Location' attribute.

This concrete attribute represents the URI of the resource that contains this this schema. It is used to complete any relative org.eclipse.xsd.XSDSchemaDirective#getSchemaLocation URI in an import, include, or redefine. No schema org.eclipse.xsd.XSDSchemaDirective#getResolvedSchema will be attempted until this has been set.
[中]返回“Schema Location”属性的值。
此具体属性表示包含此架构的资源的URI。它用于完成任何相关组织。日食xsd。XSDSchemaDirective#在导入、包含或重定义中的getSchemaLocation URI。没有架构组织。日食xsd。将尝试XSDSchemaDirective#getResolvedSchema,直到设置完毕。

代码示例

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

/**
 * Register schema
 *
 * @param schema schema to be registered
 */
public synchronized void register(XSDSchema schema) {
  schemaRegistry.put(schema.getSchemaLocation(), schema);
}

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

public String resolveSchemaLocation(XSDSchema xsdSchema,
      String namespaceURI, String schemaLocationURI) {
    try {
      URI contextUri = new URI(xsdSchema.getSchemaLocation());
      if (contextUri.isOpaque()) {
        // probably a jar:file: URL, which is opaque and thus not
        // supported by URI.resolve()
        URL contextUrl = new URL(xsdSchema.getSchemaLocation());
        return (new URL(contextUrl, schemaLocationURI)).toString();
      } else {
        return contextUri.resolve(schemaLocationURI).toString();
      }
    } catch (URISyntaxException e) {
      throw new RuntimeException(e);
    } catch (MalformedURLException e) {
      throw new RuntimeException(e);
    }
  }
}));

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

/**
 * Resolve imports and includes to local resources.
 *
 * @param schema the parent schema from which the import/include originates
 * @param uri the namespace of an import (ignored in this implementation)
 * @param location the URL of the import or include (may be relative)
 * @see SchemaLocationResolver#resolveSchemaLocation(org.eclipse.xsd.XSDSchema,
 *     java.lang.String, java.lang.String)
 */
@Override
public String resolveSchemaLocation(
    final XSDSchema schema, final String uri, final String location) {
  return resolver.resolve(location, schema.getSchemaLocation());
}

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

public String resolveSchemaLocation(
      XSDSchema xsdSchema,
      String namespaceURI,
      String schemaLocationURI) {
    try {
      URI contextUri = new URI(xsdSchema.getSchemaLocation());
      if (contextUri.isOpaque()) {
        // probably a jar:file: URL, which is opaque and
        // thus not
        // supported by URI.resolve()
        URL contextUrl =
            new URL(xsdSchema.getSchemaLocation());
        return (new URL(contextUrl, schemaLocationURI))
            .toString();
      } else {
        return contextUri
            .resolve(schemaLocationURI)
            .toString();
      }
    } catch (URISyntaxException e) {
      throw new RuntimeException(e);
    } catch (MalformedURLException e) {
      throw new RuntimeException(e);
    }
  }
}));

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

schemaLocation = getSchemaLocation();
} else {
  schemaLocation = schema.getSchemaLocation();

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

schemaLocation = getSchemaLocation();
} else {
  schemaLocation = schema.getSchemaLocation();

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

file = findSchemaFile( schema.getSchemaLocation() );	
logger.log( Level.SEVERE, "Could not find: " + schema.getSchemaLocation() + " to copy." );

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

file = findSchemaFile( schema.getSchemaLocation() );
logger.log( Level.SEVERE, "Could not find: " + schema.getSchemaLocation() + " to copy." );

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

public String resolveSchemaLocation(XSDSchema xsdSchema, String namespaceURI,
      String schemaLocationURI) {
    try {
      URI contextUri = new URI(xsdSchema.getSchemaLocation());
      if (contextUri.isOpaque()) {
        // probably a jar:file: URL, which is opaque and thus not
        // supported by URI.resolve()
        URL contextUrl = new URL(xsdSchema.getSchemaLocation());
        return (new URL(contextUrl, schemaLocationURI)).toString();
      } else {
        return contextUri.resolve(schemaLocationURI).toString();
      }
    } catch (URISyntaxException e) {
      throw new RuntimeException(e);
    } catch (MalformedURLException e) {
      throw new RuntimeException(e);
    }
  }
}));

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

protected HashMap createFileMap(List visitedSchemas)
{
 HashMap fileMap = new HashMap();
 for (Iterator i = visitedSchemas.iterator(); i.hasNext(); )
 {
  XSDSchema theSchema = (XSDSchema)i.next();
  String location = theSchema.getSchemaLocation();       
  IFile file = computeFile(location);
  if (file != null)
  {
   fileMap.put(file, Boolean.TRUE);
  }       
 }   
 return fileMap;
}

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

@Override
public String getText(Object object)
{
 XSDSchema xsdSchema = (XSDSchema)object;
 String result = xsdSchema.getSchemaLocation();
 if (result == null)
 {
  return "";
 } 
 else
 {
  return URI.createURI(result).lastSegment();
 }
}

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

public String resolveSchemaLocation(XSDSchema schema, String uri, String location) {
    String schemaLocation;
    if (schema == null) {
      schemaLocation = getSchemaLocation();
    } else {
      schemaLocation = schema.getSchemaLocation();
    }
    String locationUri = null;
    if ((null != schemaLocation) && !("".equals(schemaLocation))) {
      String schemaLocationFolder = schemaLocation;
      int lastSlash = schemaLocation.lastIndexOf('/');
      if (lastSlash > 0) {
        schemaLocationFolder = schemaLocation.substring(0, lastSlash);
      }
      if (schemaLocationFolder.startsWith("file:")) {
        schemaLocationFolder = schemaLocationFolder.substring(5);
      }
      File locationFile = new File(schemaLocationFolder, location);
      if (locationFile.exists()) {
        locationUri = locationFile.toURI().toString();
      }
    }
    if ((locationUri == null) && (location != null) && location.startsWith("http:")) {
      locationUri = location;
    }
    return locationUri;
  }
};

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

public String resolveSchemaLocation(XSDSchema xsdSchema, String namespaceURI, String schemaLocationURI)
{
 String baseLocation = xsdSchema.getSchemaLocation();      
 String result = URIResolverPlugin.createResolver().resolve(baseLocation, namespaceURI, schemaLocationURI);
 if (result == null) {
   result = namespaceURI;
 }
 if (result == null) {
   result = "";
 }
 return result;
}

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

public IFile getFile(Object component)
{
 IFile result = null;
 if (component instanceof ComponentSpecification)
 {
  result = ((ComponentSpecification)component).getFile();
 }  
 else if (component instanceof SearchMatch)
 {
  result = ((SearchMatch)component).getFile();
 }  
 else if (component instanceof XSDConcreteComponent)
 {
  XSDConcreteComponent concreteComponent = (XSDConcreteComponent)component;
  XSDSchema schema = concreteComponent.getSchema();
  if (schema != null)
  {
   // TODO (cs) revisit and test more
   //
   String location = schema.getSchemaLocation();
   String platformResource = "platform:/resource";
   if (location != null && location.startsWith(platformResource))
   {
    Path path = new Path(location.substring(platformResource.length()));
    result = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
   }  
  }  
 }
 return result;
}

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

private void addDeclarationUpdate(TextChangeManager manager)
{
  String fileStr = getModel().getSchemaLocation();
  URI uri = URI.createPlatformResourceURI(fileStr);
  try
  {
    URL url = new URL(uri.toString());
    url = Platform.resolve(url);
    if(url != null){
      IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
      IFile file = root.getFileForLocation(new Path(url.getFile()));
      if(file != null ){
        TextChange change = manager.get(file);
        addDeclarationUpdate(change);
      }
    }
  } catch (MalformedURLException e)
  {
    // TODO Auto-generated catch block
    e.printStackTrace();
  } catch (IOException e)
  {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
  
  
}

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

public String getLocationURI() 
{
 if (getLocationURIGen() == null)
 {
  XSDConcreteComponent thePrimaryComponent = getPrimaryComponent();
  if (thePrimaryComponent != null)
  {
   XSDSchema xsdSchema = thePrimaryComponent.getSchema();
   if (xsdSchema != null)
   {
    return xsdSchema.getSchemaLocation();
   }
  }
 }
 return getLocationURIGen();
}

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

public String getLocationURI() 
{
 if (getLocationURIGen() == null)
 {
  XSDConcreteComponent thePrimaryComponent = getPrimaryComponent();
  if (thePrimaryComponent != null)
  {
   XSDSchema xsdSchema = thePrimaryComponent.getSchema();
   if (xsdSchema != null)
   {
    return xsdSchema.getSchemaLocation();
   }
  }
 }
 return getLocationURIGen();
}

代码示例来源:origin: org.geotools/gt-app-schema

public AttributeDescriptor getDescriptor(final Name descriptorName,
    XSDComplexTypeDefinition typeDef, XSDElementDeclaration elemDecl,
    CoordinateReferenceSystem crs) {
  AttributeDescriptor descriptor = descriptorRegistry.get(descriptorName);
  if (descriptor == null) {
    try {
      if (elemDecl == null) {
        elemDecl = getElementDeclaration(descriptorName);
      }
    } catch (NoSuchElementException e) {
      String msg = "Type not found for "
          + descriptorName
          + " at type container "
          + (typeDef == null ? null : typeDef.getTargetNamespace() + "#"
              + typeDef.getName() + " at "
              + typeDef.getSchema().getSchemaLocation());
      NoSuchElementException nse = new NoSuchElementException(msg);
      nse.initCause(e);
      throw nse;
    }
    descriptor = createAttributeDescriptor(typeDef, elemDecl, crs);
    LOGGER.finest("Registering attribute descriptor " + descriptor.getName());
    register(descriptor);
  }
  return descriptor;
}

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

public static void openXSDEditor(XSDConcreteComponent xsdComponent)
{
 XSDSchema schema = xsdComponent.getSchema();
 if (schema != null)
 {
  String schemaLocation = URIHelper.removePlatformResourceProtocol(schema.getSchemaLocation());
  IPath schemaPath = new Path(schemaLocation);
  IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(schemaPath);
  if (file != null && file.exists())
  {
   IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   if (workbenchWindow != null)
   {
    IWorkbenchPage page = workbenchWindow.getActivePage();
    try
    {
     IEditorPart editorPart = IDE.openEditor(page, file, true);
     if (editorPart instanceof InternalXSDMultiPageEditor)
     {
      InternalXSDMultiPageEditor xsdEditor = (InternalXSDMultiPageEditor) editorPart;
      xsdEditor.openOnGlobalReference(xsdComponent);
     }
    }
    catch (PartInitException pie)
    {
    }
   }
  }
 }         
}

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

return XSDConstants.resolveSchemaLocation(xsdSchema.getSchemaLocation(), namespace, schemaLocation);

相关文章

微信公众号

最新文章

更多