Package org.eclipse.emf.ecore.xmi

Examples of org.eclipse.emf.ecore.xmi.XMLResource


   */
 
  public Resource load(String systemId, Map<?, ?> options) throws IOException
  {
    ResourceSet resourceSet = createResourceSet();
    XMLResource resource = (XMLResource)resourceSet.createResource(URI.createURI(systemId));
    InputSource inputSource = new InputSource();
    inputSource.setSystemId(systemId);
    if (options != null)
    {
      Map<Object, Object> mergedOptions = new HashMap<Object, Object>(loadOptions);
      mergedOptions.putAll(options);
      resource.load(inputSource, mergedOptions);
    }
    else
    {
      resource.load(inputSource, loadOptions);
    }
    resourceSet.getPackageRegistry().putAll(registry);
    return resource;
  }
View Full Code Here


  }

  public Resource load(InputSource inputSource, Map<?, ?> options) throws IOException
  {
    ResourceSet resourceSet = createResourceSet();
    XMLResource resource = (XMLResource)resourceSet.createResource(XML_URI);
    if (options != null)
    {
      Map<Object, Object> mergedOptions = new HashMap<Object, Object>(loadOptions);
      mergedOptions.putAll(options);
      resource.load(inputSource, mergedOptions);
    }
    else
    {
      resource.load(inputSource, loadOptions);
    }
    resourceSet.getPackageRegistry().putAll(registry);
    return resource;
  }
View Full Code Here

  }

  public Resource load(Node node, Map<?, ?> options) throws IOException
  {
    ResourceSet resourceSet = createResourceSet();
    XMLResource resource = (XMLResource)resourceSet.createResource(XML_URI);
    if (options != null)
    {
      Map<Object, Object> mergedOptions = new HashMap<Object, Object>(loadOptions);
      mergedOptions.putAll(options);
      resource.load(node, mergedOptions);
    }
    else
    {
      resource.load(node, loadOptions);
    }
    resourceSet.getPackageRegistry().putAll(registry);
    return resource;
  }
View Full Code Here

     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public Resource createResource(URI uri) {
        XMLResource result = new DcResourceImpl(uri);
        result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
        result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);

        result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);

        result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
                Boolean.TRUE);
        result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
                Boolean.TRUE);

        result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
        return result;
    }
View Full Code Here

     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public Resource createResource(URI uri) {
        XMLResource result = new DiResourceImpl(uri);
        result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
        result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);

        result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);

        result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
                Boolean.TRUE);
        result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
                Boolean.TRUE);

        result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
        return result;
    }
View Full Code Here

  @Override
  public Map<String, Object> contentDescription(URI uri, InputStream inputStream, Map<?, ?> options, Map<Object, Object> context) throws IOException
  {
    Map<String, Object> result = super.contentDescription(uri, inputStream, options, context);

    XMLResource xmlResource = load(uri, inputStream, options, context);
    EList<EObject> contents = xmlResource.getContents();
    if (!contents.isEmpty())
    {
      EObject eObject = contents.get(0);
      if (eObject instanceof XMLTypeDocumentRoot)
      {
View Full Code Here

   * @return the XML resource loaded from the input stream.
   * @throws IOException if there is a problem loading the XML content.
   */
  protected XMLResource load(URI uri, InputStream inputStream, Map<?, ?> options, Map<Object, Object> context) throws IOException
  {
    XMLResource result = (XMLResource)context.get("XMLResource");
    if (result == null)
    {
      try
      {
        result = createXMLResource();
        result.setURI(uri);
        result.load
          (new BufferedInputStream(inputStream)
           {
             @Override
             public void close() throws IOException
             {
View Full Code Here

    @Override
    public Map<String, Object> contentDescription(URI uri, InputStream inputStream, Map<?, ?> options, Map<Object, Object> context) throws IOException
    {
      Map<String, Object> result = super.contentDescription(uri, inputStream, options, context);

      XMLResource xmlResource = load(uri, inputStream, options, context);
      EList<EObject> contents = xmlResource.getContents();
      if (!contents.isEmpty())
      {
        EObject eObject = contents.get(0);
        if (eObject instanceof XMLTypeDocumentRoot)
        {
View Full Code Here

  }

  @Override
  public Resource createResource(URI uri)
  {
    XMLResource result = new XMLResourceImpl(uri);
    result.setEncoding("UTF-8");

    result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);

    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);

    result.getDefaultSaveOptions().put(XMLResource.OPTION_LINE_WIDTH, 80);

    result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
    result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);

    result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);

    XMLOptions xmlOptions = new XMLOptionsImpl();

    xmlOptions.setProcessAnyXML(true);

    xmlOptions.setProcessSchemaLocations(true);
   
    result.getDefaultLoadOptions().put(XMLResource.OPTION_XML_OPTIONS, xmlOptions);

    return result;
  }
View Full Code Here

     * @generated
     */
  @Override
public Resource createResource(URI uri)
  {
        XMLResource result = new ConfigResourceImpl(uri);
        result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
        result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);

        result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);

        result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
        result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);

        result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
        return result;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.emf.ecore.xmi.XMLResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.