Skip to main content
summaryrefslogtreecommitdiffstats
blob: 72cc43f15436b670f67e860673159bdec16b0f2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?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