1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
4
* Use is subject to license terms.
8
<link rel="stylesheet" href="nbdocs://org.netbeans.modules.usersguide/org/netbeans/modules/usersguide/ide.css" type="text/css">
9
<title>Using Code Completion in XML Files Constrained by an XML Catalog</title>
12
<h2>Using Code Completion in XML Files Constrained by an XML Catalog</h2>
13
<p><small><a href="#seealso">See Also</a></small></p>
14
<p>You can use an XML catalog that is registered in the IDE to constrain an XML instance document.</p>
16
<p><b>To use an XML catalog to constrain a new XML document:</b></p>
18
<li>In the IDE, open the Services window.</li>
19
<li>Expand the <tt>DTD and XML Schema Catalogs</tt> node, then expand the catalog node, right-click the catalog entry node and choose View.<br>
20
The Source Editor opens the catalog entry in read-only mode.</li>
21
<li>Make a note of the <tt>targetNamespace</tt> value (<tt><i>schema-targetNamespace</i></tt>) and the root or top-level element (<tt><i>schema-root-element</i></tt>) in the schema.</li>
22
<li>In the IDE, create a new XML document by doing the following:<br>
24
<li>From the main menu, choose File > New File.<br>
25
The New File wizard opens.</li>
26
<li>Under Categories, select the <tt>XML</tt> node and under File Types, select the <tt>XML Document</tt> node, then click Next.</li>
27
<li>Specify a name and location for the document and click Next.</li>
28
<li>Select the XML Schema-Constrained Document radio button and click Next.</li>
29
<li>In the Schema Options page of the wizard, click Finish without completing any of the fields.<br>
30
The IDE creates the new XML document in the specified location.</li>
32
<li>In the XML document, select the <tt>root</tt> tag,<br>
34
<root xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
35
xsi:noNamespaceSchemaLocation='null'>
39
and replace it with the following:
41
<<i>schema-root-element</i>
42
xmlns:<i>prefix</i>='<i>schema-targetNamespace</i>'
43
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
44
xsi:schemaLocation='<i>schema-targetNamespace</i> <i>schema-targetNamespace</i>'>
46
</<i>schema-root-element</i>>
49
<li>In the Source Editor tab of the XML document, position the cursor where you want to start adding content and type an opening left angle bracket (<tt><</tt>).<br>
50
The code completion box opens. This box provides a scrolling list of schema elements. The list of elements is based on the XML schema from the XML catalog that constrains the XML instance document.</li>
54
<dt><a name="seealso">See Also</a></dt>
55
<dd><a href="nbdocs://org.netbeans.modules.usersguide/org/netbeans/modules/usersguide/xml/catalog/xmlcatalog_mount.html" title="Registering a Local DTD or XML Schema Resource">Registering a Local DTD or XML Schema Resource</a></dd>
56
<dd><a href="usingcodecompletion.html" title="About Using Code Completion in XML Instance Documents Constrained by XML Schema">About Using Code Completion in XML Instance Documents Constrained by XML Schema</a></dd>
57
<dd><a href="../about.html" title="About XML Schema Tools">About XML Schema Tools</a></dd>
60
<small><a href="../credits.html">Legal Notices</a></small>
61
<table cellpadding="150" border="0">
62
<tr><td> </td></tr>
63
<tr><td> </td></tr>
64
<tr><td> </td></tr>