本文整理汇总了Java中org.apache.xml.serializer.NamespaceMappings类的典型用法代码示例。如果您正苦于以下问题:Java NamespaceMappings类的具体用法?Java NamespaceMappings怎么用?Java NamespaceMappings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NamespaceMappings类属于org.apache.xml.serializer包,在下文中一共展示了NamespaceMappings类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureNamespaceDeclDeclared
import org.apache.xml.serializer.NamespaceMappings; //导入依赖的package包/类
/**
* This function checks to make sure a given prefix is really
* declared. It might not be, because it may be an excluded prefix.
* If it's not, it still needs to be declared at this point.
* TODO: This needs to be done at an earlier stage in the game... -sb
*
* NEEDSDOC @param dtm
* NEEDSDOC @param namespace
*
* @throws org.xml.sax.SAXException
*/
public static void ensureNamespaceDeclDeclared(
SerializationHandler handler,
DTM dtm,
int namespace)
throws org.xml.sax.SAXException
{
String uri = dtm.getNodeValue(namespace);
String prefix = dtm.getNodeNameX(namespace);
if ((uri != null && uri.length() > 0) && (null != prefix))
{
String foundURI;
NamespaceMappings ns = handler.getNamespaceMappings();
if (ns != null)
{
foundURI = ns.lookupNamespace(prefix);
if ((null == foundURI) || !foundURI.equals(uri))
{
handler.startPrefixMapping(prefix, uri, false);
}
}
}
}
示例2: resolvePrefix
import org.apache.xml.serializer.NamespaceMappings; //导入依赖的package包/类
/**
* Resolve the namespace into a prefix. At this level, if no prefix exists,
* then return a manufactured prefix.
*
* @param rhandler The current result tree handler.
* @param prefix The probable prefix if already known.
* @param nodeNamespace The namespace, which should not be null.
*
* @return The prefix to be used.
*/
protected String resolvePrefix(SerializationHandler rhandler,
String prefix, String nodeNamespace)
throws TransformerException
{
if (null != prefix && (prefix.length() == 0 || prefix.equals("xmlns")))
{
// Since we can't use default namespace, in this case we try and
// see if a prefix has already been defined or this namespace.
prefix = rhandler.getPrefix(nodeNamespace);
// System.out.println("nsPrefix: "+nsPrefix);
if (null == prefix || prefix.length() == 0 || prefix.equals("xmlns"))
{
if(nodeNamespace.length() > 0)
{
NamespaceMappings prefixMapping = rhandler.getNamespaceMappings();
prefix = prefixMapping.generateNextPrefix();
}
else
prefix = "";
}
}
return prefix;
}
示例3: setNamespaceMappings
import org.apache.xml.serializer.NamespaceMappings; //导入依赖的package包/类
public void setNamespaceMappings(NamespaceMappings mappings) {
mySerializationHandler.setNamespaceMappings(mappings);
}
示例4: getNamespaceMappings
import org.apache.xml.serializer.NamespaceMappings; //导入依赖的package包/类
public NamespaceMappings getNamespaceMappings() {
return mySerializationHandler.getNamespaceMappings();
}
示例5: setNamespaceMappings
import org.apache.xml.serializer.NamespaceMappings; //导入依赖的package包/类
public void setNamespaceMappings(NamespaceMappings arg0) {
xmlStream.setNamespaceMappings(arg0);
}
示例6: getNamespaceMappings
import org.apache.xml.serializer.NamespaceMappings; //导入依赖的package包/类
public NamespaceMappings getNamespaceMappings() {
return xmlStream.getNamespaceMappings();
}