Package nu.xom

Examples of nu.xom.Attribute


    this.controlPoint2 = null;
  }

  public Element toXML() {
    Element element = new Element("SketchPoint");
    element.addAttribute(new Attribute("x", String.valueOf(this.x)));
    element.addAttribute(new Attribute("y", String.valueOf(this.y)));

    if (this.controlPoint1 != null) {
      element.addAttribute(new Attribute("c1x", String
          .valueOf(this.controlPoint1.x)));
      element.addAttribute(new Attribute("c1y", String
          .valueOf(this.controlPoint1.y)));
    }

    if (this.controlPoint2 != null) {
      element.addAttribute(new Attribute("c2x", String
          .valueOf(this.controlPoint2.x)));
      element.addAttribute(new Attribute("c2y", String
          .valueOf(this.controlPoint2.y)));
    }

    return element;
  }
View Full Code Here


  }

  public Element toXML() {
    Element element = new Element("SketchSpline");

    element.addAttribute(new Attribute("id", String.valueOf(this.getId())));
    element.addAttribute(new Attribute("outlineId", String
        .valueOf(this.path.getId())));
    element.addAttribute(new Attribute("centreId", String.valueOf(this
        .getCentrePath().getId())));

    element.addAttribute(new Attribute("offsetSize", String.valueOf(this
        .getOffsetSize())));

    element.addAttribute(new Attribute("splineType", String.valueOf(this
        .getType())));

    element.addAttribute(new Attribute("endCap", String.valueOf(this
        .getCap())));

    element.addAttribute(new Attribute("joinType", String.valueOf(this
        .getJoinType())));


    if (isConstructionLine())
      element.addAttribute(new Attribute("isConstructionLine", "true"));

    element.addAttribute(new Attribute("union", String.valueOf(this.union)));

    Element elementCentre = new Element("SketchSplineCentrePath");
    for (int i = 0; i < this.getCentrePath().size(); i++) {
      SketchPoint point = this.getCentrePath().get(i);
      elementCentre.appendChild(point.toXML());
    }

    element.appendChild(elementCentre);

    Element SketchSplineOffsets = new Element("SketchSplineOffsets");
    for (int i = 0; i < getCentrePath().size(); i++) {
      SketchPoint curVec = (SketchPoint) getCentrePath().get(i);

      if (this.outlineOffset.containsKey(i)) {
        Vec2D offset = this.outlineOffset.get(i);
        Element SketchSplineOffset = new Element("SketchSplineOffset");
        SketchSplineOffset.addAttribute(new Attribute("linked_id",
            String.valueOf(i)));
        SketchSplineOffset.addAttribute(new Attribute("x_offset",
            String.valueOf(offset.x)));
        SketchSplineOffset.addAttribute(new Attribute("y_offset",
            String.valueOf(offset.y)));

        SketchSplineOffsets.appendChild(SketchSplineOffset);
      }

    }

    Element SketchSplinePathOffsets = new Element("SketchSplinePathOffsets");
    for (int i = 0; i < getCentrePath().size(); i++) {
      SketchPoint curVec = (SketchPoint) getCentrePath().get(i);

      if (this.getCentreOffset().containsKey(i)) {
        float offset = this.getCentreOffset().get(i);
        Element SketchSplineOffset = new Element(
            "SketchSplinePathOffset");
        SketchSplineOffset.addAttribute(new Attribute("linked_index",
            String.valueOf(i)));
        SketchSplineOffset.addAttribute(new Attribute("offset", String
            .valueOf(offset)));

        SketchSplinePathOffsets.appendChild(SketchSplineOffset);
      }

    }

    element.appendChild(SketchSplinePathOffsets);

    for (int i = 0; i < getCentrePath().size(); i++) {
      Vec2D curVec = (Vec2D) getCentrePath().get(i);
      int i2 = ((getCentrePath().size() * 2) - i - 1);

      if (this.outlineOffset.containsKey(i2)) {
        Vec2D offset = this.outlineOffset.get(i2);

        Element SketchSplineOffset = new Element("SketchSplineOffset");

        SketchSplineOffset.addAttribute(new Attribute("linked_id",
            String.valueOf(i2)));
        SketchSplineOffset.addAttribute(new Attribute("x_offset",
            String.valueOf(offset.x)));
        SketchSplineOffset.addAttribute(new Attribute("y_offset",
            String.valueOf(offset.y)));

        SketchSplineOffsets.appendChild(SketchSplineOffset);

      }
View Full Code Here

        return newNode;
    }

    @Override
    public void addAttribute(final String name, final String value) {
        top().addAttribute(new Attribute(encodeAttribute(name), value));
    }
View Full Code Here

            );
            int size = nodes.size();
            for (int j=0; j < size; j++) {
                Node node = nodes.get(j);
                if (node instanceof Attribute) {
                    Attribute attribute = (Attribute) node;
                    while (true) {
                        try {
                            element.addAttribute(attribute);
                            break;
                        }
                        catch (NamespaceConflictException ex) {
                            // According to section 7.1.3 of XSLT spec we
                            // need to remap the prefix here; ideally the
                            // XSLT processor should do this but many don't
                            // for instance, see
                            // http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5389
                            attribute.setNamespace(
                              "p"+attribute.getNamespacePrefix(),
                              attribute.getNamespaceURI()
                            );
                        }
                    }
                }
                else {
View Full Code Here

        Document doc = new Document(root);          

        for (int i = 0x20; i <= 0xD7FF; i++) {
            Element data = new Element("d");
            data.appendChild(((char) i) + "");
            data.addAttribute(new Attribute("c", String.valueOf(i)));
            root.appendChild(data);
        }
       
        // skip surrogates between 0xD800 and 0xDFFF
       
        for (int i = 0xE000; i <= 0xFFFD; i++) {
            Element data = new Element("d");
            data.appendChild(((char) i) + "");
            data.addAttribute(new Attribute("c", String.valueOf(i)));
            root.appendChild(data);
        }
       
        System.gc();

        // Plane-1 characters are tricky because Java
        // strings  encode them as surrogate pairs. First, fill 
        // a byte array with the characters from 1D100 to 1D1FF
        // (the musical symbols)
        for (int i = 0; i < 256; i++) {
            // algorithm from RFC 2781
            int u = 0x1D100 + i;
            int uprime = u - 0x10000;
            int W1 = 0xD800;
            int W2 = 0xDC00;
            W2 = W2 | (uprime & 0x7FF );
            W1 = W1 | (uprime & 0xFF800);
            Element data = new Element("d");
            data.appendChild( ((char) W1) + "" + ((char) W2) );
            data.addAttribute(new Attribute("c", String.valueOf(u)));
            root.appendChild(data);
        }
       
        return doc;
       
View Full Code Here

      if (!"".equals(prefix)) {
        System.out.println("  Namespace prefix: " + prefix);
      }
    }
    for (int i = 0; i < element.getAttributeCount(); i++) {
        Attribute attribute = element.getAttribute(i);
        String name = attribute.getQualifiedName();
        String value = attribute.getValue();
        System.out.println("  " + name + "=\"" + value + "\"");
    }
   
    for (int i = 0; i < element.getNamespaceDeclarationCount(); i++) {
        String additional = element.getNamespacePrefix(i);
View Full Code Here

        Element copy = new Element(original.getQualifiedName(),
          new String(original.getNamespaceURI()));
        if (parent != null) parent.appendChild(copy);
        for (int i = original.getAttributeCount()-1; i >= 0; i--) {
            Attribute att = original.getAttribute(i);
            copy.addAttribute(copy(att));
        }
        // Weird; need to find just the additional namespaces????
        /* for (int i = original.getNamespaceDeclarationCount()-1; i >= 0; i--) {
             copy.addNamespaceDeclaration(original.);
View Full Code Here

    }

   
    private Attribute copy(Attribute original) {
       
        Attribute copy = new Attribute(original.getQualifiedName(),
          original.getNamespaceURI(),
          original.getValue(),
          original.getType());
        return copy;
       
View Full Code Here

    Element child2 = new Element("child2");
    root.appendChild(child2);
    Element child3 = new Element("child3");
    root.appendChild(child3);
    child3.addAttribute(new Attribute("xml:base",
      "http://www.w3.org/XML/1998/namespace", base2));
    Element child4 = new Element("child4");
    root.appendChild(child4);
    child4.addAttribute(new Attribute("xml:base",
      "http://www.w3.org/XML/1998/namespace", base3));
   
    try {
        Serializer serializer
          = new Serializer(System.out, "ISO-8859-1");
View Full Code Here

    private Element copy(Element original) {

        Element copy = new Element(original.getQualifiedName(),
          original.getNamespaceURI());
        for (int i = original.getAttributeCount()-1; i >= 0; i--) {
            Attribute att = original.getAttribute(i);
            copy.addAttribute(copy(att));
        }
        // Weird; need to find just the additional namespaces????
        /* for (int i = original.getNamespaceDeclarationCount()-1; i >= 0; i--) {
             copy.addNamespaceDeclaration(original.);
View Full Code Here

TOP

Related Classes of nu.xom.Attribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.