Beispiel #1
0
  private void setNSDeclAsAttr(Attributes atts) {
    Enumeration keys = nsMap.keys();
    if (keys.hasMoreElements()) {
      if (!(atts instanceof AttributesImpl)) {
        atts = new AttributesImpl(atts);
      }
      while (keys.hasMoreElements()) {
        String prefix = (String) keys.nextElement();
        String uri = (String) nsMap.get(prefix);
        if ("".equals(prefix)) {
          int index = atts.getIndex("xmlns");
          if (index == -1) {

            ((AttributesImpl) atts).addAttribute("", "", "xmlns", "CDATA", uri);
          } else {
            ((AttributesImpl) atts).setAttribute(index, "", "", "xmlns", "CDATA", uri);
          }
        } else {
          int index = atts.getIndex("xmlns:" + prefix);
          if (index == -1) {
            ((AttributesImpl) atts).addAttribute("", "", "xmlns:" + prefix, "CDATA", uri);
          } else {
            ((AttributesImpl) atts).setAttribute(index, "", "", "xmlns:" + prefix, "CDATA", uri);
          }
        }
      }
      nsMap.clear();
    }
  }
 @Override
 public void setAttribute(
     final int index,
     final String uri,
     final String localName,
     final String qName,
     final String type,
     final String value) {
   qNames.remove(super.getQName(index));
   if (qNames.add(qName)) {
     super.setAttribute(index, uri, localName, qName, type, value);
   } else {
     handleDuplicate(qName, value);
   }
 }
    /**
     * Encodes a <code>DCPType</code> fragment for HTTP GET and POST methods.
     *
     * @param getUrl the URL of the onlineresource for HTTP GET method requests
     * @param postUrl the URL of the onlineresource for HTTP POST method requests
     */
    private void handleDcpType(String getUrl, String postUrl) {
      AttributesImpl orAtts = new AttributesImpl();
      orAtts.addAttribute("", "xmlns:xlink", "xmlns:xlink", "", XLINK_NS);
      orAtts.addAttribute("", "xlink:type", "xlink:type", "", "simple");
      orAtts.addAttribute("", "xlink:href", "xlink:href", "", getUrl);
      start("DCPType");
      start("HTTP");

      if (getUrl != null) {
        start("Get");
        element("OnlineResource", null, orAtts);
        end("Get");
      }

      if (postUrl != null) {
        orAtts.setAttribute(2, "", "xlink:href", "xlink:href", "", postUrl);
        start("Post");
        element("OnlineResource", null, orAtts);
        end("Post");
      }

      end("HTTP");
      end("DCPType");
    }