Overview of Code Completion in Schema-Constrained XML Documents
See Also
You can use code completion in XML files if the XML document is constrained by an XML schema. In the schema source file, this constraint is represented by a xsi:schemaLocation or a xsi:noNamespaceSchemaLocation attribute in the root element of the schema. Typically, xsi:schemaLocation is used for schemas with a target namespace and xsi:noNamespaceSchemaLocation is used for schemas with no target namespace.
As a general rule, if the root elements provide the necessary information to locate the schemas, the IDE will be able to offer code completion based on those schemas. The IDE will attempt to locate the schemas in the following order:
- Check the local file system to find the schema.
- If not found in the local file system, perform a lookup in the runtime catalog.
- If not found, try to fetch them from the internet, cache them locally and use them to provide CC
The code completion functionality provides two types of code completion:
- Element code completion. When you type a starting tag (<) inside an existing parent element, you will see a list of child elements for that parent element. For example, assume that your schema has parent element called purchaseOrder. When you type the starting tag (<), you will see all the child elements of purchaseOrder in the code completion box.
- Attribute code completion. When you press Spacebar inside an element tag, the code completion box will open with a list of attributes for that element.
You can use code completion in XML instance documents in several ways:
To complete an XML tag in an XML document:
- Open the XML document in the Source Editor and position the cursor where you want to start adding content and type an opening left angle bracket (<).
If you want to use code completion in an existing element, simply position your cursor within the element and press Spacebar or type any character to invoke code completion.
- Pause after step 1, or press Ctrl-Spacebar.
The code completion box opens. This box provides a scrolling list of schema elements. The list of elements is based on the XML schema file that constrains the current XML file.
- Select a value using the information in Selecting Values in the Code Completion Box.
If you select a component with attributes, the next Spacebar keystroke will invoke the code completion box with the attributes.
You can use the most convenient combination of the following options to select values in the code completion box:
- Continue typing to fine tune the selection of items in the list.
- Use the mouse or navigation keys (up and down arrows, Page Up, Page Down, Home, and End) to scroll through the list and select an entry.
- Press Enter to enter the selection in the completion box into your file and close the completion box. Alternatively, you can double-click an entry in the code completion box.
- See Also
- About XML Schema Tools
- Using Code Completion
- Registering a Local DTD or XML Schema Resource
Legal Notices