Skip to main content
summaryrefslogblamecommitdiffstats
blob: 72cc43f15436b670f67e860673159bdec16b0f2e (plain) (tree)












































































































































                                                                                                                              
<?xml version='1.0'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>

  <head>

    <title>Using JET Transformations with XML Documents</title>

    <link charset="ISO-8859-1" href="../book.css" rel="STYLESHEET"
     type="text/css"/>

  </head>

  <body>

    <h2>Using JET Transformations with XML Documents</h2>

    <p>By default, JET transformations expect an XML documents as 
    input. XML documents are loaded into memory using the Eclipse 
    Modeling Framework (EMF) XML document support</p>

    <h3>XPath expressions against XML documents</h3>

    <p>The JET XPath processor handles XML documents according to the 
    XPath 1.0 specification, with the following exception:</p>

    <ul>

      <li>The XPath processor matches expressions containing 
      unqualified names with elements and attributes that use include a 
      namespace prefix. XPath expressions can still determine the 
      namespace URI of an element or attribute via the 
      <a href="http://www.w3.org/TR/xpath#function-namespace-uri">
      namespace-uri</a> XPath function.</li>

    </ul>

    <h3>Details of XML Document loading</h3>

    <p>JET uses EMF&apos;s 
    <a href="PLUGINS_ROOT/org.eclipse.emf.doc/references/javadoc/org/eclipse/emf/ecore/xml/type/util/XMLTypeResourceImpl.html"
    >XMLTypeResoureImpl</a> to load XML documents. Documents are loaded 
    as follows:</p>

    <ul>

      <li>If the document contains an XML schema declaration, and the 
      Eclipse XSD feature is installed (org.eclipse.xsd), and the XSD 
      location can be located, then the document is loaded according to 
      the XSD.</li>

      <li>When loading with an XSD, EMF will use the Java classes 
      registered against the schema, if they exist. Otherwise, Dynamic 
      <a href="PLUGINS_ROOT/org.eclipse.emf.doc/references/javadoc/org/eclipse/emf/ecore/EClass.html"
      >EClasses</a> will be generated, and loaded objects will be of 
      type 
      <a href="PLUGINS_ROOT/org.eclipse.emf.doc/references/javadoc/org/eclipse/emf/ecore/EObject.html"
      >EObject</a>.</li>

      <li>If no XSD schema is supplied, or the schema cannot be located 
      and there are no registered EMF Java classes for the schema, then 
      XML elements are loaded as instances of 
      <a href="PLUGINS_ROOT/org.eclipse.emf.doc/references/javadoc/org/eclipse/emf/ecore/xml/type/AnyType.html"
      >AnyType</a>.</li>

    </ul>

    <p>The Model loader id for XML document loading is 
    <code>org.eclipse.jet.emfxml</code>.</p>

    <h3>Loading XML documents during transformation execution</h3>

    <p>XML documents my by loaded using the 
    <a href="PLUGINS_ROOT/org.eclipse.jet.doc/references/taglibs/controlTags/loadTag.html"
    >&lt;c:load&gt;</a> and 
    <a href="PLUGINS_ROOT/org.eclipse.jet.doc/references/taglibs/controlTags/loadContentTag.html"
    >&lt;c:loadContent&gt;</a> tags. The former loads a document from 
    an file, while the second loads the document by parsing a text 
    string.</p>

    <p>The following loads the plugin.xml file from the 
    transformation:</p>

    <p><code>&lt;c:load url=&quot;plugin.xml&quot; 
    var=&quot;pluginXML&quot;/&gt;</code></p>

    <p>This is equivalent to:</p>

    <p><code>&lt;c:load url=&quot;plugin.xml&quot; 
    urlContext=&quot;transform&quot; 
    loader=&quot;org.eclipse.jet.emfxml&quot; 
    var=&quot;pluginXML&quot;/&gt;</code></p>

    <p>The following example loads the plugin.xml document from a 
    project &apos;myproject&apos; in the Eclipse workspace.</p>

    <p><code>&lt;c:load url=&quot;myproject/plugin.xml&quot; 
    urlContext=&quot;workspace&quot; 
    var=&quot;pluginXML&quot;/&gt;</code></p>

    <p>Finally, this example loads the contents of the c:loadContent 
    tag as an XML document:</p>

    <pre>&lt;c:loadContent var=&quot;myDoc&quot;&gt;
    &lt;parts&gt;
        &lt;item sku=&quot;123&quot; price=&quot;1.55&quot;&gt;Widget A&lt;/item&gt;
        &lt;item sku=&quot;456&quot; price=&quot;2.99&quot;&gt;Widget B&lt;/item&gt;
    &lt;/parts&gt;
&lt;/c:loadContent&gt;</pre>
    <h3>Loading XML documents with non-standard extensions</h3>

    <p>The XML model loader is only associated with the &apos;xml&apos; 
    file extension. To load documents with other extensions as XML 
    documents, configure the transformation as follows:</p>

    <ul>

      <li>Open the plugin.xml file in the root of the JET 
      transformation project.</li>

      <li>Switch to the &apos;Extensions&apos; tab.</li>

      <li>Find the &apos;org.eclipse.jet.transform&apos; extension in 
      the &apos;All Extensions&apos; tree, and expand it to reveal the 
      &apos;transform&apos; child element.</li>

      <li>Select the &apos;transform&apos; element, and enter 
      <code>org.eclipse.jet.emfxml</code> in the 
      &apos;modelLoader&apos; field, and <code>xml</code> in the 
      &apos;modelExtension&apos; field.</li>

    </ul>

    <p>
    <img alt="Image of plug-in editor showing setting of &apos;modelLoader&apos; and &apos;modelExtension&apos; attributes."
     src="images/forceXMLLoader.png"/></p>

  </body>

</html>

Back to the top