use of org.apache.xalan.extensions.ExtensionNamespacesManager in project robovm by robovm.
the class ElemExtensionDecl method compose.
public void compose(StylesheetRoot sroot) throws TransformerException {
super.compose(sroot);
String prefix = getPrefix();
String declNamespace = getNamespaceForPrefix(prefix);
String lang = null;
String srcURL = null;
String scriptSrc = null;
if (null == declNamespace)
throw new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_NO_NAMESPACE_DECL, new Object[] { prefix }));
//"Prefix " + prefix does not have a corresponding namespace declaration");
for (ElemTemplateElement child = getFirstChildElem(); child != null; child = child.getNextSiblingElem()) {
if (Constants.ELEMNAME_EXTENSIONSCRIPT == child.getXSLToken()) {
ElemExtensionScript sdecl = (ElemExtensionScript) child;
lang = sdecl.getLang();
srcURL = sdecl.getSrc();
ElemTemplateElement childOfSDecl = sdecl.getFirstChildElem();
if (null != childOfSDecl) {
if (Constants.ELEMNAME_TEXTLITERALRESULT == childOfSDecl.getXSLToken()) {
ElemTextLiteral tl = (ElemTextLiteral) childOfSDecl;
char[] chars = tl.getChars();
scriptSrc = new String(chars);
if (scriptSrc.trim().length() == 0)
scriptSrc = null;
}
}
}
}
if (null == lang)
lang = "javaclass";
if (lang.equals("javaclass") && (scriptSrc != null))
throw new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_ELEM_CONTENT_NOT_ALLOWED, new Object[] { scriptSrc }));
//"Element content not allowed for lang=javaclass " + scriptSrc);
// Register the extension namespace if it has not already been registered.
ExtensionNamespaceSupport extNsSpt = null;
ExtensionNamespacesManager extNsMgr = sroot.getExtensionNamespacesManager();
if (extNsMgr.namespaceIndex(declNamespace, extNsMgr.getExtensions()) == -1) {
if (lang.equals("javaclass")) {
if (null == srcURL) {
extNsSpt = extNsMgr.defineJavaNamespace(declNamespace);
} else if (extNsMgr.namespaceIndex(srcURL, extNsMgr.getExtensions()) == -1) {
extNsSpt = extNsMgr.defineJavaNamespace(declNamespace, srcURL);
}
} else // not java
{
String handler = "org.apache.xalan.extensions.ExtensionHandlerGeneral";
Object[] args = { declNamespace, this.m_elements, this.m_functions, lang, srcURL, scriptSrc, getSystemId() };
extNsSpt = new ExtensionNamespaceSupport(declNamespace, handler, args);
}
}
if (extNsSpt != null)
extNsMgr.registerExtension(extNsSpt);
}
use of org.apache.xalan.extensions.ExtensionNamespacesManager in project j2objc by google.
the class ElemExtensionDecl method compose.
public void compose(StylesheetRoot sroot) throws TransformerException {
super.compose(sroot);
String prefix = getPrefix();
String declNamespace = getNamespaceForPrefix(prefix);
String lang = null;
String srcURL = null;
String scriptSrc = null;
if (null == declNamespace)
throw new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_NO_NAMESPACE_DECL, new Object[] { prefix }));
// "Prefix " + prefix does not have a corresponding namespace declaration");
for (ElemTemplateElement child = getFirstChildElem(); child != null; child = child.getNextSiblingElem()) {
if (Constants.ELEMNAME_EXTENSIONSCRIPT == child.getXSLToken()) {
ElemExtensionScript sdecl = (ElemExtensionScript) child;
lang = sdecl.getLang();
srcURL = sdecl.getSrc();
ElemTemplateElement childOfSDecl = sdecl.getFirstChildElem();
if (null != childOfSDecl) {
if (Constants.ELEMNAME_TEXTLITERALRESULT == childOfSDecl.getXSLToken()) {
ElemTextLiteral tl = (ElemTextLiteral) childOfSDecl;
char[] chars = tl.getChars();
scriptSrc = new String(chars);
if (scriptSrc.trim().length() == 0)
scriptSrc = null;
}
}
}
}
if (null == lang)
lang = "javaclass";
if (lang.equals("javaclass") && (scriptSrc != null))
throw new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_ELEM_CONTENT_NOT_ALLOWED, new Object[] { scriptSrc }));
// "Element content not allowed for lang=javaclass " + scriptSrc);
// Register the extension namespace if it has not already been registered.
ExtensionNamespaceSupport extNsSpt = null;
ExtensionNamespacesManager extNsMgr = sroot.getExtensionNamespacesManager();
if (extNsMgr.namespaceIndex(declNamespace, extNsMgr.getExtensions()) == -1) {
if (lang.equals("javaclass")) {
if (null == srcURL) {
extNsSpt = extNsMgr.defineJavaNamespace(declNamespace);
} else if (extNsMgr.namespaceIndex(srcURL, extNsMgr.getExtensions()) == -1) {
extNsSpt = extNsMgr.defineJavaNamespace(declNamespace, srcURL);
}
} else // not java
{
String handler = "org.apache.xalan.extensions.ExtensionHandlerGeneral";
Object[] args = { declNamespace, this.m_elements, this.m_functions, lang, srcURL, scriptSrc, getSystemId() };
extNsSpt = new ExtensionNamespaceSupport(declNamespace, handler, args);
}
}
if (extNsSpt != null)
extNsMgr.registerExtension(extNsSpt);
}
Aggregations