本文整理汇总了Java中org.xml.sax.helpers.NamespaceSupport.getURI方法的典型用法代码示例。如果您正苦于以下问题:Java NamespaceSupport.getURI方法的具体用法?Java NamespaceSupport.getURI怎么用?Java NamespaceSupport.getURI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xml.sax.helpers.NamespaceSupport
的用法示例。
在下文中一共展示了NamespaceSupport.getURI方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPrefixes
import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
/**
* Copy the namespace declarations from the NamespaceSupport object.
* Take care to call resolveInheritedNamespaceDecls.
* after all namespace declarations have been added.
*
* @param nsSupport non-null reference to NamespaceSupport from
* the ContentHandler.
* @param excludeXSLDecl true if XSLT namespaces should be ignored.
*
* @throws TransformerException
*/
public void setPrefixes(NamespaceSupport nsSupport, boolean excludeXSLDecl)
throws TransformerException
{
Enumeration decls = nsSupport.getDeclaredPrefixes();
while (decls.hasMoreElements())
{
String prefix = (String) decls.nextElement();
if (null == m_declaredPrefixes)
m_declaredPrefixes = new ArrayList();
String uri = nsSupport.getURI(prefix);
if (excludeXSLDecl && uri.equals(Constants.S_XSLNAMESPACEURL))
continue;
// System.out.println("setPrefixes - "+prefix+", "+uri);
XMLNSDecl decl = new XMLNSDecl(prefix, uri, false);
m_declaredPrefixes.add(decl);
}
}
示例2: XPointerFilter
import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
public XPointerFilter(
XMLReader parent,
NamespaceSupport namespaces,
String xpointer)
{
super(parent);
// We support a very rudimentary - but totally sufficient - XPointer syntax,
// which is just /element/otherelement/otherotherelement/*
if (!xpointer.startsWith("/") || !xpointer.endsWith("/*"))
throw new IllegalArgumentException("Unsupported xpointer syntax: " +
xpointer);
xpointer = xpointer.substring(0, xpointer.length() - 2).substring(1);
String[] elements = xpointer.split("/");
int count = elements.length;
_rootNamespaceURI = new String[count];
_rootLocalName = new String[count];
_acceptChildNodes = new boolean[count];
for (int i = 0; i < count; i++)
{
String[] parts = elements[i].split(":");
String prefix = (parts.length == 1) ? "" : parts[0];
String namespaceURI = namespaces.getURI(prefix);
_rootNamespaceURI[i] = (namespaceURI != null) ? namespaceURI : "";
_rootLocalName[i] = (parts.length == 1) ? parts[0] : parts[1];
_acceptChildNodes[i] = false;
}
}