FXGLog.getLogger().log(FXGLogger.WARN, "UnknownElement", null, documentName, startLine, startColumn, localName, versionHandler.getVersion().asString());
unknownElement = localName;
return;
}else
{
throw new FXGException(startLine, startColumn, "UnknownElementInVersion", root.getFileVersion().asString(), localName);
}
}
else
{
throw new FXGException(startLine, startColumn, "InvalidFXGRootNode");
}
}
// Provide access to the root document node used for querying version
// for non-root elements
if (root != null)
{
node.setDocumentNode(root);
}
// Set node name if it is a delegate node. This allows proper error
// message to be reported.
if (node instanceof DelegateNode)
{
DelegateNode propertyNode = (DelegateNode)node;
propertyNode.setName(localName);
}
// Set attributes on the current node
for (int i = 0; i < attributes.getLength(); i++)
{
String attributeURI = attributes.getURI(i);
if (attributeURI == null || attributeURI == "" ||
isFXGNamespace(attributeURI) ||
isApacheFlexNamespace(attributeURI))
{
String attributeName = attributes.getLocalName(i);
String attributeValue = attributes.getValue(i);
node.setAttribute(attributeName, attributeValue);
}
}
// Associate child with parent node (and handle any special
// relationships)
if (parent != null)
{
if (node instanceof DelegateNode)
{
DelegateNode propertyNode = (DelegateNode)node;
propertyNode.setDelegate(parent);
}
else
{
parent.addChild(node);
}
}
else if (node instanceof GraphicNode)
{
root = (GraphicNode)node;
// Provide access to the root document node
node.setDocumentNode(root);
if (root.getVersion() == null)
{
// Exception: <Graphic> doesn't have the required attribute
// "version".
throw new FXGException(startLine, startColumn, "MissingVersionAttribute");
}
else
{
if (!isMajorVersionMatch(root))
{
FXGVersionHandler newVHandler = FXGVersionHandlerRegistry.getVersionHandler(root.getVersion());
if (newVHandler == null)
{
if (REJECT_MAJOR_VERSION_MISMATCH)
{
// Exception:Major version of this FXG file is greater than
// major version supported by this compiler. Cannot process
// the file.
throw new FXGException(startLine, startColumn, "InvalidFXGVersion", root.getVersion().asString());
}
else
{
// Warning: Major version of this FXG file is greater than
// major version supported by this compiler.
FXGLog.getLogger().log(FXGLogger.WARN, "MajorVersionMismatch", null, getDocumentName(), startLine, startColumn);
//use the latest version handler
versionHandler = FXGVersionHandlerRegistry.getLatestVersionHandler();
if (versionHandler == null)
{
throw new FXGException("FXGVersionHandlerNotRegistered", root.getVersion().asString());
}
}
}
else
{
versionHandler = newVHandler;
}
}
}
// Provide reference to the handler for querying version of the
// current document processed.
root.setDocumentName(documentName);
root.setVersionGreaterThanCompiler(root.getVersion().greaterThan(versionHandler.getVersion()));
root.setReservedNodes(versionHandler.getElementNodes(uri));
root.setCompilerVersion(versionHandler.getVersion());
root.setProfile(profile);
}
else
{
// Exception:<Graphic> must be the root node of an FXG document.
throw new FXGException(startLine, startColumn, "InvalidFXGRootNode");
}
stack.push(node);
}