public class XMLTools
extends java.lang.Object
Constructor and Description |
---|
XMLTools() |
Modifier and Type | Method and Description |
---|---|
static void |
disableIEXMLHackaround()
Disables an Internet Explorer-specific work around for the MSXML bug that the 'xml' namespace
prefix cannot be explicitly declared.
|
static void |
loadWSDL(java.lang.String wsdlURL,
WSDLLoadCallback callback)
Load a WSDL file and create an instance of WebService that allows invoking operations and binding DataSources to web service operations.
|
static void |
loadWSDL(java.lang.String wsdlURL,
WSDLLoadCallback callback,
RPCRequest requestProperties)
Load a WSDL file and create an instance of WebService that allows invoking operations and binding DataSources to web service operations.
|
static void |
loadWSDL(java.lang.String wsdlURL,
WSDLLoadCallback callback,
RPCRequest requestProperties,
boolean autoLoadImports)
Load a WSDL file and create an instance of WebService that allows invoking operations and binding DataSources to web service operations.
|
static void |
loadXMLSchema(java.lang.String schemaURL,
XSDLoadCallback callback)
Load an XML file containing XML schema definitions and create DataSource and SimpleType objects to represent the schema.
|
static void |
loadXMLSchema(java.lang.String schemaURL,
XSDLoadCallback callback,
RPCRequest requestProperties)
Load an XML file containing XML schema definitions and create DataSource and SimpleType objects to represent the schema.
|
static void |
loadXMLSchema(java.lang.String schemaURL,
XSDLoadCallback callback,
RPCRequest requestProperties,
boolean autoLoadImports)
Load an XML file containing XML schema definitions and create DataSource and SimpleType objects to represent the schema.
|
static boolean |
nativeXMLAvailable()
Returns true if the current browser exposes an XML parser that can be used for Smart GWT XML operations like web service
bindings and XML processing.
|
static java.lang.Object |
selectNodes(java.lang.Object element,
java.lang.String expression)
Retrieve a set of nodes from an XML element or document based on an XPath expression.
|
static java.lang.Object |
selectNodes(java.lang.Object element,
java.lang.String expression,
java.util.Map namespaces)
Retrieve a set of nodes from an XML element or document based on an XPath expression.
|
static int |
selectNumber(java.lang.Object element,
java.lang.String expression)
Retrieve a numeric value from an XML element or document based on an XPath expression.
|
static int |
selectNumber(java.lang.Object element,
java.lang.String expression,
java.util.Map namespaces)
Retrieve a numeric value from an XML element or document based on an XPath expression.
|
static com.google.gwt.json.client.JSONArray |
selectObjects(java.lang.Object element,
java.lang.String expression)
Applies an XPath expression to JavaScript objects, returning matching objects.
|
static java.lang.String |
selectString(java.lang.Object element,
java.lang.String expression)
Retrieve a string value from an XML element or document based on an XPath expression.
|
static java.lang.String |
selectString(java.lang.Object element,
java.lang.String expression,
java.util.Map namespaces)
Retrieve a string value from an XML element or document based on an XPath expression.
|
static com.google.gwt.core.client.JavaScriptObject |
toJS(java.lang.Object elements)
Translates an XML fragment to JavaScript collections.
|
public static void disableIEXMLHackaround()
Though redundant,
the Namespaces in XML spec allows
XML documents to explicitly declare namespace prefix 'xml' bound to namespace name
http://www.w3.org/XML/1998/namespace
; e.g.
xmlns:xml="http://www.w3.org/XML/1998/namespace"MSXML does not allow the 'xml' namespace prefix to be declared, and will raise the XML parse error: The namespace prefix is not allowed to start with the reserved string "xml". Microsoft has disclosed this bug as a Normative Variation in MSXML: http://msdn.microsoft.com/en-us/library/ff460535(v=vs.85).aspx. A framework-level work around is used by default in
parseXML()
where
if the
string xmlns:xml="http://www.w3.org/XML/1998/namespace"
or
xmlns:xml='http://www.w3.org/XML/1998/namespace'
is found in the first 1000
characters of the xmlText
parameter to parseXML(), then these two strings are
removed from xmlText
wherever they appear. This work around may be disabled by
calling disableIEXMLHackaround() at any time before parseXML() is called.public static boolean nativeXMLAvailable()
PlatformDependencies
for more information on when the
XML parser may not available and what features are impacted as a result.public static void loadXMLSchema(java.lang.String schemaURL, XSDLoadCallback callback)
All <xsd:complexType> declarations become ISC DataSources, and all <xsd:simpleType> definitions become atomic type definitions.
By default, named complexType definitions and named element definitions containing complexTypes become global DataSources, that is, they can be fetched with DataSource.getDataSource(). Inline complexType definitions get automatically generated names.
Named simpleType declarations become global ISC atomic types, that is, subsequently defined DataSources can use them for DataSourceField.type. XML schema "restrictions" for simple types are automatically translated to DataSourceField.valueMap or DataSourceField.validators as appropriate.
The created SchemaSet object is available in the callback as the single parameter "schemaSet", or can retrieved via SchemaSet.get(schemaNamespace).
NOTE: required fields: the XML concept of "required" for an attribute or subelement, expressed via use="required" (for an attribute) or minOccurs > 0 (for a subelement), is that the attribute or element must be present in the XML document but can have any value, including being empty or null. The SmartGWT notion of required means non-null. You can express the SmartClient notion of required in XML Schema with the combination of maxOccurs>0 and a minLength or length "restriction", and SmartClient will recognize the field as SmartClient-required, with all of the behaviors that implies (eg, specially styled form titles, automatic validation, etc).
schemaURL
- URL to load the schema fromcallback
- the callbackpublic static void loadXMLSchema(java.lang.String schemaURL, XSDLoadCallback callback, RPCRequest requestProperties)
All <xsd:complexType> declarations become ISC DataSources, and all <xsd:simpleType> definitions become atomic type definitions.
By default, named complexType definitions and named element definitions containing complexTypes become global DataSources, that is, they can be fetched with DataSource.getDataSource(). Inline complexType definitions get automatically generated names.
Named simpleType declarations become global ISC atomic types, that is, subsequently defined DataSources can use them for DataSourceField.type. XML schema "restrictions" for simple types are automatically translated to DataSourceField.valueMap or DataSourceField.validators as appropriate.
The created SchemaSet object is available in the callback as the single parameter "schemaSet", or can retrieved via SchemaSet.get(schemaNamespace).
NOTE: required fields: the XML concept of "required" for an attribute or subelement, expressed via use="required" (for an attribute) or minOccurs > 0 (for a subelement), is that the attribute or element must be present in the XML document but can have any value, including being empty or null. The SmartGWT notion of required means non-null. You can express the SmartClient notion of required in XML Schema with the combination of maxOccurs>0 and a minLength or length "restriction", and SmartClient will recognize the field as SmartClient-required, with all of the behaviors that implies (eg, specially styled form titles, automatic validation, etc).
schemaURL
- URL to load the schema fromcallback
- the callbackrequestProperties
- additional properties to set on the RPCRequest that will be issuedpublic static void loadXMLSchema(java.lang.String schemaURL, XSDLoadCallback callback, RPCRequest requestProperties, boolean autoLoadImports)
All <xsd:complexType> declarations become ISC DataSources, and all <xsd:simpleType> definitions become atomic type definitions.
By default, named complexType definitions and named element definitions containing complexTypes become global DataSources, that is, they can be fetched with DataSource.getDataSource(). Inline complexType definitions get automatically generated names.
Named simpleType declarations become global ISC atomic types, that is, subsequently defined DataSources can use them for DataSourceField.type. XML schema "restrictions" for simple types are automatically translated to DataSourceField.valueMap or DataSourceField.validators as appropriate.
The created SchemaSet object is available in the callback as the single parameter "schemaSet", or can retrieved via SchemaSet.get(schemaNamespace).
NOTE: required fields: the XML concept of "required" for an attribute or subelement, expressed via use="required" (for an attribute) or minOccurs > 0 (for a subelement), is that the attribute or element must be present in the XML document but can have any value, including being empty or null. The SmartGWT notion of required means non-null. You can express the SmartClient notion of required in XML Schema with the combination of maxOccurs>0 and a minLength or length "restriction", and SmartClient will recognize the field as SmartClient-required, with all of the behaviors that implies (eg, specially styled form titles, automatic validation, etc).
schemaURL
- URL to load the schema fromcallback
- the callbackrequestProperties
- additional properties to set on the RPCRequest that will be issuedautoLoadImports
- if set, xsd:
The callback will not fire until all dependencies have been loadedpublic static void loadWSDL(java.lang.String wsdlURL, WSDLLoadCallback callback)
XML Schema present in the WSDL file will also will also be processed as described in XMLTools.loadXMLSchema().
Platform notes: loadWSDL() is not supported in Safari 2.0 (but is supported in Safari 3.0.3 and greater)
wsdlURL
- URL to load the WSDL file fromcallback
- the callbackpublic static void loadWSDL(java.lang.String wsdlURL, WSDLLoadCallback callback, RPCRequest requestProperties)
XML Schema present in the WSDL file will also will also be processed as described in XMLTools.loadXMLSchema().
Platform notes: loadWSDL() is not supported in Safari 2.0 (but is supported in Safari 3.0.3 and greater)
wsdlURL
- URL to load the WSDL file fromcallback
- the callbackrequestProperties
- additional properties to set on the RPCRequest that will be issuedpublic static void loadWSDL(java.lang.String wsdlURL, WSDLLoadCallback callback, RPCRequest requestProperties, boolean autoLoadImports)
XML Schema present in the WSDL file will also will also be processed as described in XMLTools.loadXMLSchema().
Platform notes: loadWSDL() is not supported in Safari 2.0 (but is supported in Safari 3.0.3 and greater)
wsdlURL
- URL to load the WSDL file fromcallback
- the callbackrequestProperties
- additional properties to set on the RPCRequest that will be issuedautoLoadImports
- if set, xsd:
The callback will not fire until all dependencies have been loadedpublic static java.lang.String selectString(java.lang.Object element, java.lang.String expression)
Namespacing works as described under XMLTools.selectNodes()
NOTE: this API cannot be supported on the Safari web browser for versions prior to 3.0.3.
element
- Native XMLElement, document or String xml to select fromexpression
- XPath expression to use to select nodespublic static java.lang.String selectString(java.lang.Object element, java.lang.String expression, java.util.Map namespaces)
Namespacing works as described under XMLTools.selectNodes()
NOTE: this API cannot be supported on the Safari web browser for versions prior to 3.0.3.
element
- Native XMLElement, document or String xml to select fromexpression
- XPath expression to use to select nodesnamespaces
- namespacespublic static java.lang.Object selectNodes(java.lang.Object element, java.lang.String expression)
element
- Native XMLElement,document or string xml to select fromexpression
- XPath expression to use to select nodespublic static java.lang.Object selectNodes(java.lang.Object element, java.lang.String expression, java.util.Map namespaces)
If the target document is namespaced, namespace prefixes declared in the document element of the target document will be available, as well as the default namespace, if declared, under the prefix "default".
To declare your own namespace prefixes, provide a prefix to URI mapping as a simple JS Object, for example:
{ az : "http://webservices.amazon.com/AWSECommerceService/2005-03-23", xsd : "http://www.w3.org/2001/XMLSchema" }NOTE: this API cannot be supported on the Safari web browser for versions earlier than 3.0.3.
element
- Native XMLElement,document to select fromexpression
- XPath expression to use to select nodesnamespaces
- namespace mapping used by the expression as prefix -> URI mappingpublic static com.google.gwt.json.client.JSONArray selectObjects(java.lang.Object element, java.lang.String expression)
element
- Object to select results fromexpression
- XPath expressionpublic static com.google.gwt.core.client.JavaScriptObject toJS(java.lang.Object elements)
elements
- XMLElement or XMLDocument element to transform to JSpublic static int selectNumber(java.lang.Object element, java.lang.String expression)
If more than one node matches, only the first node's value will be returned.
Namespacing works as described under +link{XMLTools.selectNodes()}
NOTE: this API cannot be supported on the Safari web browser for versions prior to 3.0.3.
element
- Native XMLElement, document or String xml to select fromexpression
- XPath expression to use to select nodespublic static int selectNumber(java.lang.Object element, java.lang.String expression, java.util.Map namespaces)
If more than one node matches, only the first node's value will be returned.
Namespacing works as described under +link{XMLTools.selectNodes()}
NOTE: this API cannot be supported on the Safari web browser for versions prior to 3.0.3.
element
- Native XMLElement, document or String xml to select fromexpression
- XPath expression to use to select nodesnamespaces
- namespaces