Пример #1
0
 public DNodeVisitStatus visit(DNode node) throws AbortDNodeTraversalException {
   if (node.getNodeType() != Node.ELEMENT_NODE
       || node.getParentNode() == null
       || node.getDsfNamespace() == null) {
     return DNodeVisitStatus.CONTINUE;
   }
   if (PrefixHelper.isPrefixOnly(node.getDsfNamespace())) {
     DNamespace ns2 = ((DNode) node.getParentNode()).dsfLookupNamespaceURI(node.getPrefix());
     if (ns2 != null && node.getDsfNamespace() != ns2) {
       node.setDsfNamespace(ns2);
     }
     // else, repair it to drop the prefix syntax??
   }
   // Case 2: apply to any element inside a DOM tree
   // should not do this
   //		if(node.getPrefix()==null){
   //			DNamespace ns2 = ((DNode)node.getParentNode())
   //			.dsfLookupPrefix(node.getNamespaceURI());
   //			if (ns2 != null && node.getDsfNamespace() != ns2){
   //				node.setDsfNamespace(ns2);
   //				return DNodeVisitStatus.CONTINUE ;
   //			}
   //		}
   return DNodeVisitStatus.CONTINUE;
 }
Пример #2
0
  public DNodeVisitStatus visit(DNode node) throws AbortDNodeTraversalException {
    if (node.getNodeType() != Node.ELEMENT_NODE
        || node.getParentNode() == null
        || node.getDsfNamespace() == null
        || PrefixHelper.isPrefixOnly(node.getDsfNamespace())) {
      return DNodeVisitStatus.CONTINUE;
    }

    DNamespace ns2 = ((DNode) node.getParentNode()).dsfLookupPrefix(node.getNamespaceURI());
    if (ns2 != null && node.getDsfNamespace() != ns2) {
      //			NodeList list = ((DElement) node)
      //			.getElementsByTagNameNS(ns2.getNamespaceKey(), "*");
      //			for (int i = 0; i < list.getLength(); i ++){
      //				((DElement)list.item(i)).setDsfNamespace(ns2);
      //			}
      node.setDsfNamespace(ns2);
    }
    return DNodeVisitStatus.CONTINUE;
  }
Пример #3
0
 /**
  * Check if the given namespace has prefix, but no namespaceURI. Apply for node created by
  * htmlBuilder only.
  *
  * @param ns
  * @return
  */
 public static boolean isPrefixOnly(DNamespace ns) {
   return PrefixHelper.isPrefixOnly(ns);
 }