Пример #1
0
  @Override
  public void relink_namespace(ThreadContext context) {
    Element e = (Element) node;

    e.getOwnerDocument().renameNode(e, e.lookupNamespaceURI(e.getPrefix()), e.getNodeName());

    if (e.hasAttributes()) {
      NamedNodeMap attrs = e.getAttributes();

      for (int i = 0; i < attrs.getLength(); i++) {
        Attr attr = (Attr) attrs.item(i);
        String nsUri = "";
        String prefix = attr.getPrefix();
        String nodeName = attr.getNodeName();
        if ("xml".equals(prefix)) {
          nsUri = "http://www.w3.org/XML/1998/namespace";
        } else if ("xmlns".equals(prefix) || nodeName.equals("xmlns")) {
          nsUri = "http://www.w3.org/2000/xmlns/";
        } else {
          nsUri = attr.lookupNamespaceURI(nodeName);
        }

        e.getOwnerDocument().renameNode(attr, nsUri, nodeName);
      }
    }

    if (e.hasChildNodes()) {
      ((XmlNodeSet) children(context)).relink_namespace(context);
    }
  }
Пример #2
0
  private void buildCases() throws Exception {
    List<Element> cases = INDEX_CASES.get().evalAsNativeElementList(doc);
    for (Element caseEl : cases) {
      WildcardPattern matchNamespace = null;
      WildcardPattern matchName = null;

      String matchNamespaceAttr = DocumentHelper.getAttribute(caseEl, "matchNamespace", false);

      if (matchNamespaceAttr != null) {
        // If the matchNamespace attr does not contain a wildcard expression, and its value
        // happens to be an existing namespace prefix, than substitute the prefix for the full URI.
        if (!WildcardPattern.isWildcardExpression(matchNamespaceAttr)) {
          String uri = caseEl.lookupNamespaceURI(matchNamespaceAttr);
          if (uri != null) matchNamespaceAttr = uri;
        }
        matchNamespace = new WildcardPattern(matchNamespaceAttr);
      }

      String matchNameAttr = DocumentHelper.getAttribute(caseEl, "matchName", false);

      if (matchNameAttr != null) {
        matchName = new WildcardPattern(matchNameAttr);
      }

      String vtagsSpec = DocumentHelper.getAttribute(caseEl, "vtags", false);

      Map<String, String> varPropsPattern = parseVariantPropertiesPattern(caseEl);
      Set<SchemaId> vtags = parseVersionTags(vtagsSpec);

      IndexCase indexCase = new IndexCase(matchNamespace, matchName, varPropsPattern, vtags);
      conf.addIndexCase(indexCase);
    }
  }
  /**
   * @param context
   * @param jaxwsBinding
   * @param e
   */
  private void parseParameter(
      com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context,
      JAXWSBinding jaxwsBinding,
      Element e) {
    String part = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.PART_ATTR);
    Element msgPartElm = evaluateXPathNode(e.getOwnerDocument(), part, new NamespaceContextImpl(e));
    Node msgElm = msgPartElm.getParentNode();
    // MessagePart msgPart = new MessagePart();

    String partName = XmlUtil.getAttributeOrNull(msgPartElm, "name");
    String msgName = XmlUtil.getAttributeOrNull((Element) msgElm, "name");
    if ((partName == null) || (msgName == null)) {
      return;
    }

    String element = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.ELEMENT_ATTR);
    String name = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NAME_ATTR);

    QName elementName = null;
    if (element != null) {
      String uri = e.lookupNamespaceURI(XmlUtil.getPrefix(element));
      elementName = (uri == null) ? null : new QName(uri, XmlUtil.getLocalPart(element));
    }

    jaxwsBinding.addParameter(new Parameter(msgName, partName, elementName, name));
  }
  @Override
  protected QName createQName(final String prefix, final String localName) {
    final String namespace = element.lookupNamespaceURI(prefix);
    Preconditions.checkArgument(namespace != null, "Failed to lookup prefix %s", prefix);

    final URI ns = URI.create(namespace);
    final Module module = schema.findModuleByNamespaceAndRevision(ns, null);
    Preconditions.checkArgument(module != null, "Namespace %s is not owned by a module", ns);
    return QName.create(module.getQNameModule(), localName);
  }
Пример #5
0
  private boolean checkTypeName(Element el, String typeName, String name) {
    String pfx = "";
    String tn = typeName;
    if (tn.contains(":")) {
      pfx = tn.substring(0, tn.indexOf(':'));
      tn = tn.substring(tn.indexOf(':') + 1);
    }
    pfx = el.lookupNamespaceURI(pfx);

    return tn.equals(name) && pfx.length() > 5;
  }
Пример #6
0
 protected static ArrayList<String> listeValeursBooleen(
     final String type, final Element domElement) {
   final String tns = domElement.lookupNamespaceURI(prefixeNom(type));
   final String espaceSchema = domElement.getNamespaceURI();
   if ("boolean".equals(valeurLocale(type)) && espaceSchema.equals(tns)) {
     final String[] tvalbool = {"true", "false", "1", "0"};
     final ArrayList<String> valbool = new ArrayList<String>(Arrays.asList(tvalbool));
     return (valbool);
   }
   return (null);
 }
Пример #7
0
 public void resoudreReferences(final WXSSchema schema, final WXSThing redefine) {
   if (simpleType != null) simpleType.resoudreReferences(schema, redefine);
   if (itemType != null && simpleType == null) {
     final String tns = domElement.lookupNamespaceURI(JaxeWXS.prefixeNom(itemType));
     final WXSType wxsType =
         schema.resoudreReferenceType(JaxeWXS.valeurLocale(itemType), tns, redefine);
     if (wxsType instanceof WXSSimpleType) simpleType = (WXSSimpleType) wxsType;
     else {
       final String espaceSchema = domElement.getNamespaceURI();
       if (!espaceSchema.equals(tns))
         itemType = null; // si le type n'a pas �t� r�solu il doit �tre un type des sch�mas XML
     }
   }
 }
Пример #8
0
  private QName parseQName(String qname, Element contextEl) throws IndexerConfException {
    int colonPos = qname.indexOf(":");
    if (colonPos == -1) {
      throw new IndexerConfException(
          "Field name is not a qualified name, it should include a namespace prefix: " + qname);
    }

    String prefix = qname.substring(0, colonPos);
    String localName = qname.substring(colonPos + 1);

    String uri = contextEl.lookupNamespaceURI(prefix);
    if (uri == null) {
      throw new IndexerConfException("Prefix does not resolve to a namespace: " + qname);
    }

    return new QName(uri, localName);
  }
Пример #9
0
 private void addNamespaces(Namespaces rv, Element element) {
   if (element == null) throw new RuntimeException("element must not be null");
   String myDefaultNamespace = toUri(element.lookupNamespaceURI(null));
   String parentDefaultNamespace = "";
   if (element.getParentNode() != null) {
     parentDefaultNamespace = toUri(element.getParentNode().lookupNamespaceURI(null));
   }
   if (!myDefaultNamespace.equals(parentDefaultNamespace)
       || !(element.getParentNode() instanceof Element)) {
     rv.declare(Namespace.create("", myDefaultNamespace));
   }
   NamedNodeMap attributes = element.getAttributes();
   for (int i = 0; i < attributes.getLength(); i++) {
     Attr attr = (Attr) attributes.item(i);
     if (attr.getPrefix() != null && attr.getPrefix().equals("xmlns")) {
       rv.declare(Namespace.create(attr.getLocalName(), attr.getValue()));
     }
   }
 }
Пример #10
0
  public static QName attributeQName(Element element, String attributeName) {
    QName qname = null;

    NamespaceValue namespaceValue = attributeNamespaceValue(element, attributeName);
    String text = attribute(element, attributeName);
    if (namespaceValue != null) {
      if (namespaceValue.prefix == null) {
        qname = new QName(text);
      } else {
        String uri = element.lookupNamespaceURI(namespaceValue.prefix);
        if (uri == null) {
          throw new JbpmException("unknown prefix in qname " + text);
        } else if (namespaceValue.localPart == null) {
          throw new JbpmException("no local part in qname " + text);
        } else {
          qname = new QName(uri, namespaceValue.localPart, namespaceValue.prefix);
        }
      }
    }
    return qname;
  }
Пример #11
0
  private void buildDynamicFields() throws Exception {
    List<Element> fields = DYNAMIC_INDEX_FIELDS.get().evalAsNativeElementList(doc);
    for (Element fieldEl : fields) {
      String matchNamespaceAttr = DocumentHelper.getAttribute(fieldEl, "matchNamespace", false);
      String matchNameAttr = DocumentHelper.getAttribute(fieldEl, "matchName", false);
      String matchTypeAttr = DocumentHelper.getAttribute(fieldEl, "matchType", false);
      String matchScopeAttr = DocumentHelper.getAttribute(fieldEl, "matchScope", false);
      String nameAttr = DocumentHelper.getAttribute(fieldEl, "name", true);

      WildcardPattern matchNamespace = null;
      if (matchNamespaceAttr != null) {
        // If the matchNamespace attr does not contain a wildcard expression, and its value
        // happens to be an existing namespace prefix, than substitute the prefix for the full URI.
        if (!WildcardPattern.isWildcardExpression(matchNamespaceAttr)) {
          String uri = fieldEl.lookupNamespaceURI(matchNamespaceAttr);
          if (uri != null) matchNamespaceAttr = uri;
        }
        matchNamespace = new WildcardPattern(matchNamespaceAttr);
      }

      WildcardPattern matchName = null;
      if (matchNameAttr != null) {
        matchName = new WildcardPattern(matchNameAttr);
      }

      TypePattern matchTypes = null;
      if (matchTypeAttr != null) {
        matchTypes = new TypePattern(matchTypeAttr);
      }

      Set<Scope> matchScopes = null;
      if (matchScopeAttr != null) {
        matchScopes = EnumSet.noneOf(Scope.class);
        for (String scope : COMMA_SPLITTER.split(matchScopeAttr)) {
          matchScopes.add(Scope.valueOf(scope));
        }
        if (matchScopes.isEmpty()) {
          matchScopes = null;
        }
      }

      // Be gentle to users of Lily 1.0 and warn them about attributes that are not supported
      // anymore
      if (DocumentHelper.getAttribute(fieldEl, "matchMultiValue", false) != null) {
        log.warn(
            "The attribute matchMultiValue on dynamicField is not supported anymore, it will be ignored.");
      }
      if (DocumentHelper.getAttribute(fieldEl, "matchHierarchical", false) != null) {
        log.warn(
            "The attribute matchHierarchical on dynamicField is not supported anymore, it will be ignored.");
      }

      Set<String> variables = new HashSet<String>();
      variables.add("namespace");
      variables.add("name");
      variables.add("type");
      variables.add("baseType");
      variables.add("nestedType");
      variables.add("nestedBaseType");
      variables.add("deepestNestedBaseType");
      if (matchName != null && matchName.hasWildcard()) variables.add("nameMatch");
      if (matchNamespace != null && matchNamespace.hasWildcard()) variables.add("namespaceMatch");

      Set<String> booleanVariables = new HashSet<String>();
      booleanVariables.add("list");
      booleanVariables.add("multiValue");

      NameTemplate name = new NameTemplate(nameAttr, variables, booleanVariables);

      boolean extractContent = DocumentHelper.getBooleanAttribute(fieldEl, "extractContent", false);

      String formatter = DocumentHelper.getAttribute(fieldEl, "formatter", false);
      if (formatter != null && !conf.getFormatters().hasFormatter(formatter)) {
        throw new IndexerConfException(
            "Formatter does not exist: "
                + formatter
                + " at "
                + LocationAttributes.getLocationString(fieldEl));
      }

      boolean continue_ = DocumentHelper.getBooleanAttribute(fieldEl, "continue", false);

      DynamicIndexField field =
          new DynamicIndexField(
              matchNamespace,
              matchName,
              matchTypes,
              matchScopes,
              name,
              extractContent,
              continue_,
              formatter);

      conf.addDynamicIndexField(field);
    }
  }