示例#1
0
  private SingletonMap moveNsDeclaration(BpelEntity entity, Attr attr)
      throws InvalidNamespaceException {
    String namespaceURI = attr.getValue();
    ExNamespaceContext context = entity.getNamespaceContext();
    /*
     * Fantom addition of namespace. This call will not do anything,
     * it just check correcttness of namespaceURI. If it bad then
     * InvalidNamespaceException will appear and we go to catch.
     */
    context.addNamespace(namespaceURI);

    // here we remove namespace declararation
    ((BpelEntityImpl) entity)
        .setAttribute(attr.getName(), new PrefixAttribute(attr.getName()), null);

    String localName = attr.getLocalName();
    Iterator<String> iterator = context.getPrefixes();
    boolean usePrefix = true;
    while (iterator.hasNext() && localName != null) {
      String prefix = iterator.next();
      if (localName.equals(prefix)) {
        usePrefix = false;
      }
    }
    String prefix = null;
    if (XMLNS.equals(attr.getName()) || localName == null || !usePrefix) {
      prefix = context.addNamespace(attr.getValue());
    } else {
      prefix = localName;
      context.addNamespace(localName, attr.getValue());
    }
    return new SingletonMap(localName, prefix);
  }
示例#2
0
 private void handleNsAttribute(
     BpelEntity entity, BpelEntity parent, Map<String, String> prefixMap, Attr attr) {
   String namespaceURI = attr.getValue();
   if (XMLNS.equals(attr.getName()) || (XMLNS.equals(attr.getPrefix()))) {
     if (namespaceURI.equals(entity.getPeer().getNamespaceURI())) {
       // do not touch namespace that correspond namespace of current element
       return;
     }
     ExNamespaceContext context = parent.getNamespaceContext();
     Iterator<String> iterator = context.getPrefixes();
     while (iterator.hasNext()) {
       String next = iterator.next();
       String namespace = context.getNamespaceURI(next);
       if (namespaceURI.equals(namespace)) {
         String prefixName = attr.getLocalName();
         // put prefix corresponding found namespace into map for changing it further
         if (!prefixName.equals(next)) {
           prefixMap.put(prefixName, next);
         }
         // remove namespace delcaration.
         ((BpelEntityImpl) entity)
             .setAttribute(attr.getName(), new PrefixAttribute(attr.getName()), null);
       }
     }
   }
 }