Information specific to an element or attribute. This
data is managed in the MxsdEntityTable
.
Information specific to an XSD simple or complex type.
This data is managed in the MxsdTypeTable
.
The structured content of a type is stored as a
"deterministic finite automaton" or DFA data structure, defined
in package com.ibm.etools.mft.builder.xsd.dfa
.
The DFA itself is stored as a column in the
MxsdTypeTable
.
the file an entity is defined in;
the location (or href) of the definition in the file;
whether the entity is an element or attribute (in the future, also RDB schema, table, or column);
the entity's local QName. For a global element, its namespace qualified name for a local element, either qualified or not depending on elementFormQualified; for an attribute, either qualified or not depending on attributeFormQualified;
the substitution group head element (only used for global elements in substitution groups);
the base type of the element; this is a key into the
MxsdTypeTable
.
the file an type is defined in;
the location (or href) of the definition in the file;
the entity's QName. For a global type, its the namespace qualified name; for an anonymous local type, its the empty string.
Enumerated value.
the global type this type is extending or restricting
An NL-collated list of all the names valid within the type; attribute names are prefaced with '@', element names without.
Originally, it was thought this could be presorted, but since documents will define their own prefixes, sorting is of marginal value. Therefore the alphabet is unsorted, and a sort method using a given prefix-for-namespace map will be provided instead.
MxsdCachePlugin
.
//Input to the query provided by the application MxsdEntityTable featureTable = XSIModelPlugin.getDefault().getMSetCacheSchema().getMxsdFeatureTable(); String msetName, namespace, elementLocalName; //Prepare the instruments of searching MxsdTypeTable typeTable = XSIModelPlugin.getDefault().getMSetCacheSchema().getMxsdTypeTable(); ISearchPath searchPath = new MessagingSearchPath(); searchPath.setContextResource(resource); //Query the substituting column of the table String [] where = new String[] { XsiTableModelConstants.MSET_NAME_COLUMN_NAME, XsiTableModelConstants.SUBSTITUTION_GROUP_NAME_COLUMN_NAME, XsiTableModelConstants.SUBSTITUTION_GROUP_NAMESPACE_COLUMN_NAME, }; //First value parameter is the msetName; this is indexed. //Use a QName constructed from the namespace and localName; //the application needs to convert QName prefix to namespace. //The type of the substition group column is QName, so this uses the index and is //at worst O(ln N); i.e. better than linear scalability in time Object [] value = new Object[] { msetName, elementLocalName, namespace }; //Execute the query IRow [] substitutingElements = featureTable.selectRowsWithSearchPath(where,value,searchPath); //Get some values from the row... substitutingElements[idx].getColumnValue(featureTable.ENTITY_NAME_COLUMN); substitutingElements[idx].getColumnValue(featureTable.ENTITY_NAMESPACE_COLUMN);
MxsdCachePlugin
.
//Input to the query provided by the application String msetName, namespace, typeLocalName; IFile resource; //Prepare the instruments of searching MxsdTypeTable typeTable = XSIModelPlugin.getDefault().getMSetCacheSchema().getMxsdTypeTable(); ISearchPath searchPath = new MessagingSearchPath(); searchPath.setContextResource(resource); //Query the substituting column of the table String [] where = new String[] { XsiTableModelConstants.MSET_NAME_COLUMN_NAME, XsiTableModelConstants.DERIVATION_KIND_COLUMN_NAME, XsiTableModelConstants.BASE_TYPE_NAME_COLUMN_NAME, XsiTableModelConstants.BASE_TYPE_NAMESPACE_COLUMN_NAME }; //- First value parameter is the msetName; this is indexed. //- Second parameter is the derivation kind, either MSetCacheConstants.EXTENSION // or MSetCacheConstants.RESTRICTION is allowed; to select both extensions or // restrictions ignore the column in the query. //- Third and fourth parameters are the QName constructed from the base type namespace and // localName. // The type of the substition group column is QName, so this uses the index and is // at worst O(ln N); i.e. better than linear scalability in time Object [] value = new Object[] { msetName, MSetCacheConstants.EXTENSION, elementLocalName, namespace }; //Since each query will return only the immediate child types, use a stack to //recursively visit each child types's children. Map allRows = new HashSet(); Stack traverseStack = new Stack(); traverseStack.push(value[2]); //Recursively execute the query while(!traverseStack.isEmpty()) { //Set up the query with the next QName to search value[2] = traverseStack.pop(); IRow [] extensionTypes = typeTable.selectRows(where,value); for(int i=0; i<extensionTypes.length; i++) { Object qName = extensionTypes.getColumnValue(typeTable.QNAME_COLUMN); if(allRows.containsKey(qName)) continue; traverseStack.push(qName); allRows.put(qName,extensionTypes[i]); } } //Convert allRows to an array calledSet allRowSet = allRows.values(); IRow [] result = new IRow[allRowSet.size()]; allRowSet.toArray(result); //Result is all the IRows for extensions to the type of the original Qname, //including the original type itself.