Examples of Elements


Examples of nu.xom.Elements

    partHeader.part_name = partName.getValue();
    //  may or may not have 1 or more score-instrument and
    //  midi-instrument elements
    //  score-instruments
    int x;
    Elements scoreInsts = part.getChildElements("score-instrument");
    for (x = 0; x < scoreInsts.size(); ++x )
    {  partHeader.score_instruments += scoreInsts.get(x).getValue();
      if (x < scoreInsts.size()-1)
        partHeader.score_instruments += "~";
    }
    //  midi-instruments
    Elements midiInsts = part.getChildElements("midi-instrument");
    for (x = 0; x < midiInsts.size(); ++x )
    {  Element midi_instrument = midiInsts.get(x);
      Element midi_channel = midi_instrument.getFirstChildElement("midi-channel");
      String midiChannel = (midi_channel == null) ? "" : midi_channel.getValue();
      if (midiChannel.length() > 0)
      {  partHeader.midi_instruments += midiChannel;
        partHeader.midi_instruments += "|";
      }
      Element midi_inst = midi_instrument.getFirstChildElement("midi-name");
      String midiInst = (midi_inst == null) ? "" : midi_inst.getValue();
      if (midiInst.length() < 1)
      {  Element midi_bank = midi_instrument.getFirstChildElement("midi-bank");
        midiInst = (midi_bank == null) ? "" : midi_bank.getValue();
        if (midiInst.length() < 1)
        {  Element midi_program = midi_instrument.getFirstChildElement("program");
          midiInst = (midi_program == null) ? "" : midi_program.getValue();
        }
      }
      partHeader.midi_instruments += midiInst;
      if (x < midiInsts.size()-1)
        partHeader.midi_instruments += "~";
    }
  }
View Full Code Here

Examples of nu.xom.Elements

          parsePartElementInstruments(p, partHeaders[x].midi_instruments);
       
        }
      }
    }
    Elements measures = part.getChildElements("measure");
    for (int m = 0; m < measures.size(); ++m)
    {  Element measure = measures.get(m);
      Element attributes = measure.getFirstChildElement("attributes");

      if (attributes != null)
      {  //  default key = Cmaj
        byte key = 0, scale = 0//  scale 0 = minor, 1 = major
        Element attr = attributes.getFirstChildElement("key");
        if (attr != null)
        {  Element eKey = attr.getFirstChildElement("fifths");
          if (eKey != null)
            key = Byte.parseByte(eKey.getValue());
          Element eMode = attr.getFirstChildElement("mode");
          if (eMode != null)
          {  String mode = eMode.getValue();
            if (mode.compareToIgnoreCase("major") == 0)
              scale = 0;
            else if (mode.compareToIgnoreCase("minor") == 0)
              scale = 1;
            else
                    throw new JFugueException(JFugueException.KEYSIG_EXC, mode);
          }
        }
        else
          scale = 0//  default = major
            fireKeySignatureEvent(new KeySignature(key, scale));
           
            //  divisions and beats used to calculate duration when note type not present
            Element element_divisions = attributes.getFirstChildElement("divisions");
            if (element_divisions != null)
              this.divisions = Byte.valueOf(element_divisions.getValue());
            Element element_time = attributes.getFirstChildElement("time");
            if (element_time != null)
            {  Element element_beats = element_time.getFirstChildElement("beats");
              if (element_beats != null)
                this.beats = Byte.valueOf(element_beats.getValue());
            }
      }
     
          //  tempo
      Element direction = measure.getFirstChildElement("direction");
      if (direction != null)
      {  Element directionType = direction.getFirstChildElement("direction-type");
        if (directionType != null)
        {  Element metronome = directionType.getFirstChildElement("metronome");
          if (metronome != null)
          {  Element beatUnit = metronome.getFirstChildElement("beat-unit");
            String sBeatUnit = beatUnit.getValue();
            if (sBeatUnit.compareToIgnoreCase("quarter") != 0)
              throw new JFugueException(JFugueException.BEAT_UNIT_MUST_BE_QUARTER, sBeatUnit);
            Element bpm = metronome.getFirstChildElement("per-minute");
            if (bpm != null)
            {  this.setTempo(BPMtoPPM(Float.parseFloat(bpm.getValue())));
              fireTempoEvent(new Tempo(this.getTempo()));
            }
          }
        }
      }

          //  notes
          Elements notes = measure.getChildElements("note");
//          totalMeasurePct = 0.f;
          for (int n = 0; n < notes.size(); ++n)
            parseNote(p, notes.get(n));
/*  attempt to adjust for rounding errors with un-supported durations
          //  if the total length of all the notes doesn't equal a full measure,
          //  add a pad rest
          float  minDif = (1.f / (beats * divisions));
          double  padDur = (1. - totalMeasurePct);
View Full Code Here

Examples of nu.xom.Elements

   * </pre>
   */
  public static void generateTestData(String[] args) throws Exception {
    Document doc = new Builder().build(new File(args[0])); // e.g. "romeo.xml"
    int times = Integer.parseInt(args[1]);    // e.g. 100
    Elements children = doc.getRootElement().getChildElements();
    for (int k=0; k < times; k++) {
      for (int i=0; i < children.size(); i++) {
        doc.getRootElement().appendChild(children.get(i).copy());
      }
    }
   
    FileOutputStream out = new FileOutputStream(args[2]); // e.g. "romeo100.xml"
    Serializer ser = new Serializer(out);
View Full Code Here

Examples of nu.xom.Elements

      this.doc = new Document(new Element(file.getName()));
    }
  }
 
  public void put(String rowName, String columnName, String value) {
    Elements rows = doc.getRootElement().getChildElements(rowName);
    if (rows.size() == 0) {
      doc.getRootElement().appendChild(new Element(rowName));
      rows = doc.getRootElement().getChildElements(rowName);
    }
   
    Elements cols = rows.get(0).getChildElements(columnName);
    if (cols.size() == 0) {
      rows.get(0).appendChild(new Element(columnName));
      cols = rows.get(0).getChildElements(columnName);
    }
   
    Element col = cols.get(0);
    col.removeChildren();
    col.appendChild(value);
  }
View Full Code Here

Examples of nu.xom.Elements

    col.removeChildren();
    col.appendChild(value);
  }
 
  public String get(String rowName, String columnName) {
    Elements rows = doc.getRootElement().getChildElements(rowName);
    if (rows.size() > 0) {
      Elements cols = rows.get(0).getChildElements(columnName);
      if (cols.size() > 0) {
        return cols.get(0).getValue();
      }
    }
   
    return "";
  }
View Full Code Here

Examples of nu.xom.Elements

    return XOMUtil.toPrettyXML(doc);
  }
 
  public String[] columnNames() {
    LinkedHashSet names = new LinkedHashSet();
    Elements rows = doc.getRootElement().getChildElements();
    for (int i=0; i < rows.size(); i++) {
      Elements cols = rows.get(i).getChildElements();
      for (int j=0; j < cols.size(); j++) {
        names.add(cols.get(j).getLocalName());
      }
    }
   
    String[] columnNames = new String[names.size()];
    names.toArray(columnNames);
View Full Code Here

Examples of nu.xom.Elements

    names.toArray(columnNames);
    return columnNames;
  }
 
  public String[] rowNames() {
    Elements rows = doc.getRootElement().getChildElements();
    String[] rowNames = new String[rows.size()];
    for (int i=0; i < rowNames.length; i++) {
      rowNames[i] = rows.get(i).getLocalName();
    }
    return rowNames;
  }
View Full Code Here

Examples of nu.xom.Elements

        // TODO point this, at least optionally, at the jaxen directory in the zip file instead.
        // However, first you'll have to push a jaxen 1.2.1 that fixes tests.xml.
        String base = "http://svn.jaxen.codehaus.org/browse/~raw,r=trunk/jaxen/trunk/jaxen/";
        Builder builder = new Builder();
        Document testDoc = builder.build(base + "xml/test/tests.xml");
        Elements documents = testDoc.getRootElement().getChildElements("document");
        for (int i = 0; i < documents.size(); i++) {
            Element documentElement = documents.get(i);
            String url = documentElement.getAttributeValue("url");
            Document source = builder.build(
              "http://svn.jaxen.codehaus.org/browse/~raw,r=trunk/jaxen/trunk/jaxen/"
              + url);
            Elements contextElements = documentElement.getChildElements("context");
            for (int j = 0; j < contextElements.size(); j++) {
                Element contextElement = contextElements.get(j);
                   
                // skip tests that use variables
                // because XOM doesn't support variables in
                // XPath expressions
                if (queryUsesVars(contextElement)) continue;
               
                String xpath = contextElement.getAttributeValue("select");
                XPathContext namespaces = getXPathContext(contextElement);
                Node context = source.query(xpath).get(0);
               
                // process counts
                Elements tests = contextElement.getChildElements("test");
                for (int k = 0; k < tests.size(); k++) {
                    Element test = tests.get(k);
                   
                    String select = test.getAttributeValue("select");
                    Attribute countAttribute = test.getAttribute("count");
                    int count = -1;
                    if (countAttribute != null) {
                        count = Integer.parseInt(countAttribute.getValue());
                    }
                   
                    boolean exceptional = false;
                    String exception = test.getAttributeValue("exception");
                    if ("true".equals(exception)) {
                        exceptional = true;
                    }
                   
                    if (exceptional) {
                        try {
                            context.query(select, namespaces);
                            fail("Evaluated " + select);
                        }
                        catch (XPathException success) {
                            assertNotNull(success.getMessage());
                        }
                    }
                    else {
                        try {
                            Nodes results = context.query(select, namespaces);
                            if (count != -1) {
                                assertEquals(select, count, results.size());
                            }
                            Elements valueOfs = test.getChildElements("valueOf");
                            for (int v = 0; v < valueOfs.size(); v++) {
                                Element vo = valueOfs.get(v);
                                checkValueOf(results.get(0), vo, namespaces);
                            }
                        }
                        catch (XPathException ex) {
                            if (ex.getMessage().equalsIgnoreCase("XPath error: No such function document")
                              || ex.getMessage().equalsIgnoreCase("XPath error: No such function evaluate")) {
                                continue;
                            }
                            throw ex;
                        }

                    }
                }
               
                // process valueOfs
                Elements valueOfs = contextElement.getChildElements("valueOf");
                for (int k = 0; k < valueOfs.size(); k++) {
                    checkValueOf(context, valueOfs.get(k), namespaces);
                }
               
            }
        }
    }
View Full Code Here

Examples of org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.xhtml.Elements

    private void addDocForExample(final List<Doc> docs, final String example) {
        if (!isEmpty(example)) {
            final Doc doc = new Doc();

            final Elements pElement = Elements.el("p")
                    .add(Elements.val("h6", "Example"))
                    .add(Elements.el("pre").add(Elements.val("code", example)));

            doc.getContent().add(pElement);
            docs.add(doc);
View Full Code Here

Examples of org.jitterbit.xml.Elements

            }
        }
    }

    private Element findDatabaseStructureElement(String inputOrOutput) {
        Elements nodes = Elements.matching("Entity/" + inputOrOutput + "Structure", dom);
        if (nodes.getLength() == 1) {
            Element e = nodes.item(0);
            String type = e.getAttribute("type");
            if (DataStructureType.Database.name().equals(type)) {
                return e;
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.