public static ConnectorDocument convertToConnectorSchema(XmlObject xmlObject) throws XmlException {
if (ConnectorDocument.type.equals(xmlObject.schemaType())) {
validateDD(xmlObject);
return (ConnectorDocument) xmlObject;
}
XmlCursor cursor = xmlObject.newCursor();
XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
String publicId = xmlDocumentProperties.getDoctypePublicId();
try {
if ("-//Sun Microsystems, Inc.//DTD Connector 1.0//EN".equals(publicId)) {
XmlCursor moveable = xmlObject.newCursor();
try {
String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd";
String version = "1.5";
convertToSchema(cursor, J2EE_NAMESPACE, schemaLocationURL, version);
cursor.toStartDoc();
cursor.toChild(J2EE_NAMESPACE, "connector");
cursor.toFirstChild();
convertToDescriptionGroup(cursor, moveable);
cursor.toNextSibling(J2EE_NAMESPACE, "spec-version");
cursor.removeXml();
cursor.toNextSibling(J2EE_NAMESPACE, "version");
cursor.setName(RESOURCE_ADAPTER_VERSION);
cursor.toNextSibling(J2EE_NAMESPACE, "resourceadapter");
moveable.toCursor(cursor);
cursor.toFirstChild();
cursor.beginElement("outbound-resourceadapter", J2EE_NAMESPACE);
cursor.beginElement("connection-definition", J2EE_NAMESPACE);
moveable.toChild(J2EE_NAMESPACE, "managedconnectionfactory-class");
moveable.push();
//from moveable to cursor
moveable.moveXml(cursor);
while (moveable.toNextSibling(J2EE_NAMESPACE, "config-property")) {
moveable.moveXml(cursor);
}
moveable.pop();
moveable.toNextSibling(J2EE_NAMESPACE, "connectionfactory-interface");
moveable.moveXml(cursor);
moveable.toNextSibling(J2EE_NAMESPACE, "connectionfactory-impl-class");
moveable.moveXml(cursor);
moveable.toNextSibling(J2EE_NAMESPACE, "connection-interface");
moveable.moveXml(cursor);
moveable.toNextSibling(J2EE_NAMESPACE, "connection-impl-class");
moveable.moveXml(cursor);
//get out of connection-definition element
cursor.toNextToken();
moveable.toNextSibling(J2EE_NAMESPACE, "transaction-support");
moveable.moveXml(cursor);
while (moveable.toNextSibling(J2EE_NAMESPACE, "authentication-mechanism")) {
moveable.moveXml(cursor);
}
moveable.toNextSibling(J2EE_NAMESPACE, "reauthentication-support");
moveable.moveXml(cursor);
} finally {
moveable.dispose();
}
}
} finally {
cursor.dispose();