public synchronized TemplateModel executeQuery(Object context, String xpathQuery)
     throws TemplateModelException {
   if (!(context instanceof Node)) {
     if (context != null) {
       if (isNodeList(context)) {
         int cnt = ((List) context).size();
         if (cnt != 0) {
           throw new TemplateModelException(
               "Cannot perform an XPath query against a node set of "
                   + cnt
                   + " nodes. Expecting a single node."
                   + ERRMSG_RECOMMEND_JAXEN);
         } else {
           throw new TemplateModelException(ERRMSG_EMPTY_NODE_SET);
         }
       } else {
         throw new TemplateModelException(
             "Cannot perform an XPath query against a "
                 + context.getClass().getName()
                 + ". Expecting a single org.w3c.dom.Node.");
       }
     } else {
       throw new TemplateModelException(ERRMSG_EMPTY_NODE_SET);
     }
   }
   Node node = (Node) context;
   try {
     XPath xpath = new XPath(xpathQuery, null, customPrefixResolver, XPath.SELECT, null);
     int ctxtNode = xpathContext.getDTMHandleFromNode(node);
     XObject xresult = xpath.execute(xpathContext, ctxtNode, customPrefixResolver);
     if (xresult instanceof XNodeSet) {
       NodeListModel result = new NodeListModel(node);
       result.xpathSupport = this;
       NodeIterator nodeIterator = xresult.nodeset();
       Node n;
       do {
         n = nodeIterator.nextNode();
         if (n != null) {
           result.add(n);
         }
       } while (n != null);
       return result.size() == 1 ? result.get(0) : result;
     }
     if (xresult instanceof XBoolean) {
       return ((XBoolean) xresult).bool() ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
     }
     if (xresult instanceof XNull) {
       return null;
     }
     if (xresult instanceof XString) {
       return new SimpleScalar(xresult.toString());
     }
     if (xresult instanceof XNumber) {
       return new SimpleNumber(new Double(((XNumber) xresult).num()));
     }
     throw new TemplateModelException("Cannot deal with type: " + xresult.getClass().getName());
   } catch (TransformerException te) {
     throw new TemplateModelException(te);
   }
 }
Exemplo n.º 2
0
  /**
   * Performs an XPATH lookup in an xml document whose filename is specified by the first parameter
   * (assumed to be in the auxiliary subdirectory) The XPATH expression is supplied as the second
   * string parameter The return value is of type string e.g. this is currently used primarily for
   * looking up the Company Prefix Index for encoding a GS1 Company Prefix into a 64-bit EPC tag
   */
  private String xpathlookup(String xml, String expression) {

    try {

      // Parse the XML as a W3C document.
      DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      Document document =
          builder.parse(new File(xmldir + File.separator + "auxiliary" + File.separator + xml));

      XPath xpath = XPathFactory.newInstance().newXPath();

      String rv = (String) xpath.evaluate(expression, document, XPathConstants.STRING);

      return rv;

    } catch (ParserConfigurationException e) {
      System.err.println("ParserConfigurationException caught...");
      e.printStackTrace();
      return null;
    } catch (XPathExpressionException e) {
      System.err.println("XPathExpressionException caught...");
      e.printStackTrace();
      return null;
    } catch (SAXException e) {
      System.err.println("SAXException caught...");
      e.printStackTrace();
      return null;
    } catch (IOException e) {
      System.err.println("IOException caught...");
      e.printStackTrace();
      return null;
    }
  }
 {
   try {
     appletClassXPression = xPath.compile("/applet-app/applet/applet-class/text()"); // NOI18N
     appletAIDXPression = xPath.compile("/applet-app/applet/applet-AID/text()"); // NOI18N
   } catch (XPathExpressionException e) {
     Exceptions.printStackTrace(e);
   }
 }
 private String getConfigValue(String setting, String name, Document doc)
     throws XPathExpressionException {
   XPathFactory xPathfactory = XPathFactory.newInstance();
   XPath xpath = xPathfactory.newXPath();
   XPathExpression userExpr =
       xpath.compile(
           "wikipediaminer/setting[@name=\""
               + setting
               + "\"]/param[@name=\""
               + name
               + "\"]/@value");
   return userExpr.evaluate(doc);
 }
Exemplo n.º 5
0
 static void assertAD(
     Document d,
     @SuppressWarnings("unused") String mname,
     String name,
     String id,
     String min,
     String max,
     String deflt,
     int cardinality,
     String type,
     String description,
     @SuppressWarnings("unused") String[] optionvalues,
     @SuppressWarnings("unused") String optionLabels[])
     throws XPathExpressionException {
   assertEquals(
       name, xpath.evaluate("//OCD/AD[@id='" + id + "']/@name", d, XPathConstants.STRING));
   assertEquals(id, xpath.evaluate("//OCD/AD[@id='" + id + "']/@id", d, XPathConstants.STRING));
   assertEquals(
       min == null ? "" : min,
       xpath.evaluate("//OCD/AD[@id='" + id + "']/@min", d, XPathConstants.STRING));
   assertEquals(
       max == null ? "" : max,
       xpath.evaluate("//OCD/AD[@id='" + id + "']/@max", d, XPathConstants.STRING));
   assertEquals(
       deflt == null ? "" : deflt,
       xpath.evaluate("//OCD/AD[@id='" + id + "']/@deflt", d, XPathConstants.STRING));
   assertEquals(
       cardinality + "",
       xpath.evaluate("//OCD/AD[@id='" + id + "']/@cardinality", d, XPathConstants.STRING));
   assertEquals(
       type, xpath.evaluate("//OCD/AD[@id='" + id + "']/@type", d, XPathConstants.STRING));
   assertEquals(
       description == null ? "" : description,
       xpath.evaluate("//OCD/AD[@id='" + id + "']/@description", d, XPathConstants.STRING));
 }
Exemplo n.º 6
0
  static {
    try {
      dbf.setNamespaceAware(true);
      db = dbf.newDocumentBuilder();
      xpath.setNamespaceContext(
          new NamespaceContext() {

            @Override
            public Iterator<String> getPrefixes(String namespaceURI) {
              return Arrays.asList("md").iterator();
            }

            @Override
            public String getPrefix(String namespaceURI) {
              return "md";
            }

            @Override
            public String getNamespaceURI(String prefix) {
              return "http://www.osgi.org/xmlns/metatype/v1.1.0";
            }
          });
    } catch (ParserConfigurationException e) {
      e.printStackTrace();
      throw new ExceptionInInitializerError(e);
    }
  }
 /**
  * Checks if there is a servlet element with specified Servlet name.
  *
  * @param servletName Servlet name to check.
  * @return <code>true</code> if servle with specified name is present, <code>false</code>
  *     otherwise.
  */
 public boolean isAppletDefined(String appletAID) {
   try {
     XPathExpression xPression =
         xPath.compile("/applet-app/applet/applet-AID[text()='" + appletAID + "']"); // NOI18N
     return (Boolean) xPression.evaluate(doc, XPathConstants.BOOLEAN);
   } catch (XPathExpressionException ex) {
     return false;
   }
 }
Exemplo n.º 8
0
 private NodeList findNodes(Document doc, Node operation) {
   List<Node> xpaths = getChildNodes(operation, "xpath");
   if (xpaths.isEmpty()) {
     return null;
   }
   String xpathExpression = xpaths.get(0).getTextContent();
   if (xpathExpression == null) {
     return null;
   }
   XPathFactory xPathfactory = XPathFactory.newInstance();
   XPath xpath = xPathfactory.newXPath();
   NodeList nl = null;
   try {
     XPathExpression expr = xpath.compile(xpathExpression);
     nl = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
   } catch (XPathExpressionException ex) {
     Utils.onError(new Error.WrongXpathExpression(xpathExpression));
   }
   return nl;
 }
Exemplo n.º 9
0
  public static void testSimple() throws Exception {
    Builder b = new Builder();
    b.addClasspath(new File("bin"));
    b.setProperty("Export-Package", "test.metatype");
    b.setProperty("-metatype", "*");
    b.build();
    Resource r =
        b.getJar().getResource("OSGI-INF/metatype/test.metatype.MetatypeTest$TestSimple.xml");
    assertEquals(0, b.getErrors().size());
    assertEquals(0, b.getWarnings().size());
    System.err.println(b.getJar().getResources().keySet());
    assertNotNull(r);
    IO.copy(r.openInputStream(), System.err);

    Document d = db.parse(r.openInputStream());

    assertEquals("TestSimple", xpath.evaluate("//OCD/@name", d));
    assertEquals("simple", xpath.evaluate("//OCD/@description", d));
    assertEquals("test.metatype.MetatypeTest$TestSimple", xpath.evaluate("//OCD/@id", d));
    assertEquals("test.metatype.MetatypeTest$TestSimple", xpath.evaluate("//Designate/@pid", d));
    assertEquals("test.metatype.MetatypeTest$TestSimple", xpath.evaluate("//Object/@ocdref", d));
    assertEquals("simple", xpath.evaluate("//OCD/AD[@id='simple']/@id", d));
    assertEquals("Simple", xpath.evaluate("//OCD/AD[@id='simple']/@name", d));
    assertEquals("String", xpath.evaluate("//OCD/AD[@id='simple']/@type", d));
    assertEquals("true", xpath.evaluate("//OCD/AD[@id='notSoSimple']/@required", d));
    /**
     * https://github.com/bndtools/bnd/issues/281
     *
     * <p>Using the Bnd annotations library (1.52.3), the generated metatype file will have
     * required='false' for all fields annotated with @Meta.AD(). When this annotation is omitted,
     * or when the required property is explicitly set, the field is correctly marked as required.
     * Taking a glance at the code, the bug appears to be due to aQute.bnd.osgi.Annotation using
     * aQute.bnd.annotation.metatype.Configurable internally for bridging Bnd-annotations to
     * Java-annotations. This configurable only obtains the values from the Bnd-annotation, omitting
     * the defaults defined in the Java annotation. The workaround is to explicitly mention the
     * required property on each field annotated with @Meta.AD.
     */
    assertEquals("true", xpath.evaluate("//OCD/AD[@id='simple']/@required", d));
    assertEquals(
        Integer.MAX_VALUE + "", xpath.evaluate("//OCD/AD[@id='notSoSimple']/@cardinality", d));
  }
Exemplo n.º 10
0
  static void assertOCD(
      Builder b,
      String cname,
      String id,
      String name,
      String description,
      String designate,
      boolean factory,
      String localization)
      throws Exception {
    Resource r = b.getJar().getResource("OSGI-INF/metatype/" + cname + ".xml");
    assertNotNull(r);
    IO.copy(r.openInputStream(), System.err);
    Document d = db.parse(r.openInputStream());
    assertEquals(id, xpath.evaluate("//OCD/@id", d, XPathConstants.STRING));
    assertEquals(name, xpath.evaluate("//OCD/@name", d, XPathConstants.STRING));
    assertEquals(
        localization == null ? cname : localization,
        xpath.evaluate("//OCD/@localization", d, XPathConstants.STRING));
    assertEquals(
        description == null ? "" : description,
        xpath.evaluate("//OCD/@description", d, XPathConstants.STRING));

    if (designate == null) {
      assertEquals(id, xpath.evaluate("//Designate/@pid", d, XPathConstants.STRING));
      if (factory)
        assertEquals(id, xpath.evaluate("//Designate/@factoryPid", d, XPathConstants.STRING));
    } else {
      assertEquals(designate, xpath.evaluate("//Designate/@pid", d, XPathConstants.STRING));
      if (factory)
        assertEquals(
            designate, xpath.evaluate("//Designate/@factoryPid", d, XPathConstants.STRING));
    }

    assertEquals(id, xpath.evaluate("//Object/@ocdref", d, XPathConstants.STRING));
  }
Exemplo n.º 11
0
  public void parseStartup(File file) {
    Logger.getLogger(com.bombdiggity.amazon.ec2.install.Installer.class)
        .info((new StringBuilder("InstallParser.parseStartup: ")).append(file).toString());
    try {
      Document doc = loadFile(file);
      if (doc != null) {
        XPathFactory factory = XMLUtils.newXPathFactory();
        XPath xpath = factory.newXPath();
        String rootXPath = "/Startup/Commands/*";
        Element root = doc.getDocumentElement();
        XPathExpression rootExp = xpath.compile(rootXPath);
        NodeList streamList = (NodeList) rootExp.evaluate(root, XPathConstants.NODESET);
        if (streamList != null) {
          for (int i = 0; i < streamList.getLength(); i++) {
            Node streamNode = streamList.item(i);
            Element streamElem = (Element) streamNode;
            if (streamElem.getNodeName().toLowerCase().equals("install")) {
              String packageName = null;
              String folderPath = null;
              for (Node child = streamNode.getFirstChild();
                  child != null;
                  child = child.getNextSibling())
                if (child.getNodeName().toLowerCase().equals("package"))
                  packageName = XMLUtils.getNodeValue(child).trim();
                else if (child.getNodeName().toLowerCase().equals("folder"))
                  folderPath = XMLUtils.getNodeValue(child).trim();

              if (packageName != null) InstallCommands.installPackage(session, packageName);
              else if (folderPath != null) InstallCommands.installFolder(session, folderPath);
              else
                Logger.getLogger(com.bombdiggity.amazon.ec2.install.InstallParser.class)
                    .error("StartupParser.loadFile: <Install>: <Package> or <Folder> required");
            } else if (streamElem.getNodeName().toLowerCase().equals("download")) {
              String url = null;
              String method = "get";
              String data = null;
              String destination = "/opt";
              String action = null;
              List headers = new ArrayList();
              for (Node child = streamNode.getFirstChild();
                  child != null;
                  child = child.getNextSibling())
                if (child.getNodeName().toLowerCase().equals("url"))
                  url = XMLUtils.getNodeValue(child).trim();
                else if (child.getNodeName().toLowerCase().equals("method"))
                  method = XMLUtils.getNodeValue(child).toLowerCase().trim();
                else if (child.getNodeName().toLowerCase().equals("data"))
                  data = XMLUtils.getNodeValue(child).trim();
                else if (child.getNodeName().toLowerCase().equals("destination"))
                  destination = XMLUtils.getNodeValue(child).trim();
                else if (child.getNodeName().toLowerCase().equals("action"))
                  action = XMLUtils.getNodeValue(child).toLowerCase().trim();
                else if (child.getNodeName().toLowerCase().equals("header")) {
                  Node nameNode = XMLUtils.getNodeByTagName((Element) child, "Name");
                  Node valueNode = XMLUtils.getNodeByTagName((Element) child, "Value");
                  if (nameNode != null && valueNode != null) {
                    Map namePair = new HashMap();
                    namePair.put(
                        XMLUtils.getNodeValue(nameNode).trim(),
                        XMLUtils.getNodeValue(valueNode).trim());
                    headers.add(namePair);
                  } else {
                    Logger.getLogger(com.bombdiggity.amazon.ec2.install.InstallParser.class)
                        .error(
                            "StartupParser.loadFile: <Download/Header>: <Name> and <Value> required");
                  }
                }

              if (url != null && destination != null)
                InstallCommands.downloadFile(
                    session, url, method, data, headers, destination, action);
              else
                Logger.getLogger(com.bombdiggity.amazon.ec2.install.InstallParser.class)
                    .error("StartupParser.loadFile: <Download>: <URL> and <Destination> required");
            } else if (streamElem.getNodeName().toLowerCase().equals("s3fetch")) {
              String awsAccessKeyId = null;
              String awsSecretAccessKey = null;
              String bucket = null;
              String key = null;
              String destination = null;
              String action = null;
              for (Node child = streamNode.getFirstChild();
                  child != null;
                  child = child.getNextSibling())
                if (child.getNodeName().toLowerCase().equals("awsaccesskeyid"))
                  awsAccessKeyId = XMLUtils.getNodeValue(child).trim();
                else if (child.getNodeName().toLowerCase().equals("awssecretaccesskey"))
                  awsSecretAccessKey = XMLUtils.getNodeValue(child).trim();
                else if (child.getNodeName().toLowerCase().equals("bucket"))
                  bucket = XMLUtils.getNodeValue(child).trim();
                else if (child.getNodeName().toLowerCase().equals("key"))
                  key = XMLUtils.getNodeValue(child).trim();
                else if (child.getNodeName().toLowerCase().equals("destination"))
                  destination = XMLUtils.getNodeValue(child).trim();
                else if (child.getNodeName().toLowerCase().equals("action"))
                  action = XMLUtils.getNodeValue(child).toLowerCase().trim();

              if (awsAccessKeyId != null
                  && awsSecretAccessKey != null
                  && bucket != null
                  && key != null
                  && destination != null)
                InstallCommands.fetchFile(
                    session, awsAccessKeyId, awsSecretAccessKey, bucket, key, destination, action);
              else
                Logger.getLogger(com.bombdiggity.amazon.ec2.install.InstallParser.class)
                    .error(
                        "StartupParser.loadFile: <Fetch>: <AWSAccessKeyId>, <AWSSecretAccessKey>, <Bucket>, <Key> and <Destination> required");
            } else if (streamElem.getNodeName().toLowerCase().equals("runscript")) {
              String script = null;
              List params = new ArrayList();
              for (Node child = streamNode.getFirstChild();
                  child != null;
                  child = child.getNextSibling())
                if (child.getNodeName().toLowerCase().equals("script"))
                  script = XMLUtils.getNodeValue(child).trim();
                else if (child.getNodeName().toLowerCase().equals("param")) {
                  String param = XMLUtils.getNodeValue(child).trim();
                  params.add(param);
                }

              if (script != null) InstallCommands.runScript(session, script, params);
              else
                Logger.getLogger(com.bombdiggity.amazon.ec2.install.InstallParser.class)
                    .error("StartupParser.loadFile: <RunScript>: <Script> required");
            }
          }
        }
      }
    } catch (Exception e) {
      Logger.getLogger(com.bombdiggity.amazon.ec2.install.InstallParser.class)
          .error(
              (new StringBuilder("InstallParser.parseStartup: ")).append(e.toString()).toString());
      e.printStackTrace();
    }
  }
Exemplo n.º 12
0
  public static void main(String[] args) {
    try {
      DocumentBuilderFactory db = DocumentBuilderFactory.newInstance();
      DocumentBuilder builder = db.newDocumentBuilder();
      Document dom = builder.parse("data/geographic-area-data.html");
      XPathFactory xpath = XPathFactory.newInstance();
      XPath path = xpath.newXPath();
      XPathExpression table =
          path.compile("//div[@id='mw-content-text']/table[contains(@class,'wikitable')]/tr");
      NodeList wikiData = (NodeList) table.evaluate(dom, XPathConstants.NODESET);

      NodeList children;
      String currentData, cleanData;

      /* Open output stream */
      FileWriter fstream = new FileWriter("data/parsed.yaml");
      BufferedWriter out = new BufferedWriter(fstream);

      for (int i = 0; i < wikiData.getLength(); i++) {
        if (i == 0) {
          continue;
        }
        out.write(new Integer(i).toString() + ":\n");
        children = wikiData.item(i).getChildNodes();
        for (int j = 0; j < children.getLength(); j++) {
          currentData = (String) children.item(j).getTextContent();
          switch (j) {
            case 0:
              /* Current Data is empty */
              break;
            case 1:
              cleanData = decompose(currentData).trim().replaceAll("[^a-zA-Z\\s]+", "");
              out.write("\t\"Geographic entity\": \"" + cleanData + "\"\n");
              break;
            case 2:
              /* Current Data is empty */
              break;
            case 3:
              cleanData = decompose(currentData).trim().replaceAll(",", "");
              out.write("\t\"Area\": \"" + cleanData + "\"\n");
              break;
            case 4:
              /* Current Data is empty */
              break;
            case 5:
              cleanData = decompose(currentData).trim();
              out.write("\t\"Notes\": \"" + cleanData + "\"\n");
              break;
            case 6:
              /* Current Data is empty */
              break;
            default:
              /* System.out.println("[" + j + "] Hit default case statement. Current Data is: " + currentData); */
              break;
          }
        }
      }
      /* Close output stream */
      out.close();
    } catch (Exception e) {
      System.out.println(e);
    }
  }
  @Override
  public HashSet<ScoredAnnotation> solveSa2W(String text) throws AnnotationException {
    HashSet<ScoredAnnotation> res;
    try {
      res = new HashSet<ScoredAnnotation>();
      lastTime = Calendar.getInstance().getTimeInMillis();

      URL wikiApi = new URL(url);
      String parameters =
          "references=true&repeatMode=all&minProbability=0.0&source="
              + URLEncoder.encode(text, "UTF-8");
      HttpURLConnection slConnection = (HttpURLConnection) wikiApi.openConnection();
      slConnection.setRequestProperty("accept", "text/xml");
      slConnection.setDoOutput(true);
      slConnection.setDoInput(true);
      slConnection.setRequestMethod("POST");
      slConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
      slConnection.setRequestProperty("charset", "utf-8");
      slConnection.setRequestProperty(
          "Content-Length", "" + Integer.toString(parameters.getBytes().length));
      slConnection.setUseCaches(false);

      DataOutputStream wr = new DataOutputStream(slConnection.getOutputStream());
      wr.writeBytes(parameters);
      wr.flush();
      wr.close();
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      DocumentBuilder builder = factory.newDocumentBuilder();
      Document doc = builder.parse(slConnection.getInputStream());

      /*			URL wikiApi = new URL(url+"?references=true&repeatMode=all&minProbability=0.0&source="+URLEncoder.encode(text, "UTF-8"));
      			URLConnection wikiConnection = wikiApi.openConnection();
      			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      			DocumentBuilder builder = factory.newDocumentBuilder();
      			Document doc = builder.parse(wikiConnection.getInputStream());
      */

      lastTime = Calendar.getInstance().getTimeInMillis() - lastTime;

      XPathFactory xPathfactory = XPathFactory.newInstance();
      XPath xpath = xPathfactory.newXPath();
      XPathExpression idExpr = xpath.compile("//detectedTopic/@id");
      XPathExpression weightExpr = xpath.compile("//detectedTopic/@weight");
      XPathExpression referenceExpr = xpath.compile("//detectedTopic/references");

      NodeList ids = (NodeList) idExpr.evaluate(doc, XPathConstants.NODESET);
      NodeList weights = (NodeList) weightExpr.evaluate(doc, XPathConstants.NODESET);
      NodeList references = (NodeList) referenceExpr.evaluate(doc, XPathConstants.NODESET);

      for (int i = 0; i < weights.getLength(); i++) {
        if (weights.item(i).getNodeType() != Node.TEXT_NODE) {
          int id = Integer.parseInt(ids.item(i).getNodeValue());
          float weight = Float.parseFloat(weights.item(i).getNodeValue());
          //					System.out.println("ID="+ids.item(i).getNodeValue()+" weight="+weight);
          XPathExpression startExpr =
              xpath.compile("//detectedTopic[@id=" + id + "]/references/reference/@start");
          XPathExpression endExpr =
              xpath.compile("//detectedTopic[@id=" + id + "]/references/reference/@end");
          NodeList starts =
              (NodeList) startExpr.evaluate(references.item(i), XPathConstants.NODESET);
          NodeList ends = (NodeList) endExpr.evaluate(references.item(i), XPathConstants.NODESET);
          for (int j = 0; j < starts.getLength(); j++) {
            int start = Integer.parseInt(starts.item(j).getNodeValue());
            int end = Integer.parseInt(ends.item(j).getNodeValue());
            int len = end - start;
            res.add(new ScoredAnnotation(start, len, id, weight));
          }
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      throw new AnnotationException(
          "An error occurred while querying Wikipedia Miner API. Message: " + e.getMessage());
    }
    return res;
  }
Exemplo n.º 14
0
  public static void testReturnTypes() throws Exception {
    Builder b = new Builder();
    b.addClasspath(new File("bin"));
    b.setProperty("Export-Package", "test.metatype");
    b.setProperty("-metatype", "*");
    b.build();
    Resource r =
        b.getJar().getResource("OSGI-INF/metatype/test.metatype.MetatypeTest$TestReturnTypes.xml");
    assertEquals(0, b.getErrors().size());
    assertEquals(0, b.getWarnings().size());
    System.err.println(b.getJar().getResources().keySet());
    assertNotNull(r);
    IO.copy(r.openInputStream(), System.err);

    Document d = db.parse(r.openInputStream());
    assertEquals(
        "http://www.osgi.org/xmlns/metatype/v1.1.0", d.getDocumentElement().getNamespaceURI());
    // Primitives
    assertEquals("Boolean", xpath.evaluate("//OCD/AD[@id='rpBoolean']/@type", d));
    assertEquals("Byte", xpath.evaluate("//OCD/AD[@id='rpByte']/@type", d));
    assertEquals("Character", xpath.evaluate("//OCD/AD[@id='rpCharacter']/@type", d));
    assertEquals("Short", xpath.evaluate("//OCD/AD[@id='rpShort']/@type", d));
    assertEquals("Integer", xpath.evaluate("//OCD/AD[@id='rpInt']/@type", d));
    assertEquals("Long", xpath.evaluate("//OCD/AD[@id='rpLong']/@type", d));
    assertEquals("Float", xpath.evaluate("//OCD/AD[@id='rpFloat']/@type", d));
    assertEquals("Double", xpath.evaluate("//OCD/AD[@id='rpDouble']/@type", d));

    // Primitive Wrappers
    assertEquals("Boolean", xpath.evaluate("//OCD/AD[@id='rBoolean']/@type", d));
    assertEquals("Byte", xpath.evaluate("//OCD/AD[@id='rByte']/@type", d));
    assertEquals("Character", xpath.evaluate("//OCD/AD[@id='rCharacter']/@type", d));
    assertEquals("Short", xpath.evaluate("//OCD/AD[@id='rShort']/@type", d));
    assertEquals("Integer", xpath.evaluate("//OCD/AD[@id='rInt']/@type", d));
    assertEquals("Long", xpath.evaluate("//OCD/AD[@id='rLong']/@type", d));
    assertEquals("Float", xpath.evaluate("//OCD/AD[@id='rFloat']/@type", d));
    assertEquals("Double", xpath.evaluate("//OCD/AD[@id='rDouble']/@type", d));

    // Primitive Arrays
    assertEquals("Boolean", xpath.evaluate("//OCD/AD[@id='rpaBoolean']/@type", d));
    assertEquals("Byte", xpath.evaluate("//OCD/AD[@id='rpaByte']/@type", d));
    assertEquals("Character", xpath.evaluate("//OCD/AD[@id='rpaCharacter']/@type", d));
    assertEquals("Short", xpath.evaluate("//OCD/AD[@id='rpaShort']/@type", d));
    assertEquals("Integer", xpath.evaluate("//OCD/AD[@id='rpaInt']/@type", d));
    assertEquals("Long", xpath.evaluate("//OCD/AD[@id='rpaLong']/@type", d));
    assertEquals("Float", xpath.evaluate("//OCD/AD[@id='rpaFloat']/@type", d));
    assertEquals("Double", xpath.evaluate("//OCD/AD[@id='rpaDouble']/@type", d));

    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='rpaBoolean']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='rpaByte']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='rpaCharacter']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='rpaShort']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='rpaInt']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='rpaLong']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='rpaFloat']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='rpaDouble']/@cardinality", d));

    // Wrapper + Object arrays
    assertEquals("Boolean", xpath.evaluate("//OCD/AD[@id='raBoolean']/@type", d));
    assertEquals("Byte", xpath.evaluate("//OCD/AD[@id='raByte']/@type", d));
    assertEquals("Character", xpath.evaluate("//OCD/AD[@id='raCharacter']/@type", d));
    assertEquals("Short", xpath.evaluate("//OCD/AD[@id='raShort']/@type", d));
    assertEquals("Integer", xpath.evaluate("//OCD/AD[@id='raInt']/@type", d));
    assertEquals("Long", xpath.evaluate("//OCD/AD[@id='raLong']/@type", d));
    assertEquals("Float", xpath.evaluate("//OCD/AD[@id='raFloat']/@type", d));
    assertEquals("Double", xpath.evaluate("//OCD/AD[@id='raDouble']/@type", d));
    assertEquals("String", xpath.evaluate("//OCD/AD[@id='raString']/@type", d));
    assertEquals("String", xpath.evaluate("//OCD/AD[@id='raURI']/@type", d));

    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='raBoolean']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='raByte']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='raCharacter']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='raShort']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='raInt']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='raLong']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='raFloat']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='raDouble']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='raString']/@cardinality", d));
    assertEquals("2147483647", xpath.evaluate("//OCD/AD[@id='raURI']/@cardinality", d));

    // Wrapper + Object collections
    assertEquals("Boolean", xpath.evaluate("//OCD/AD[@id='rBooleans']/@type", d));
    assertEquals("Byte", xpath.evaluate("//OCD/AD[@id='rBytes']/@type", d));
    assertEquals("Character", xpath.evaluate("//OCD/AD[@id='rCharacter']/@type", d));
    assertEquals("Short", xpath.evaluate("//OCD/AD[@id='rShorts']/@type", d));
    assertEquals("Integer", xpath.evaluate("//OCD/AD[@id='rInts']/@type", d));
    assertEquals("Long", xpath.evaluate("//OCD/AD[@id='rLongs']/@type", d));
    assertEquals("Float", xpath.evaluate("//OCD/AD[@id='rFloats']/@type", d));
    assertEquals("Double", xpath.evaluate("//OCD/AD[@id='rDoubles']/@type", d));
    assertEquals("String", xpath.evaluate("//OCD/AD[@id='rStrings']/@type", d));
    assertEquals("String", xpath.evaluate("//OCD/AD[@id='rURIs']/@type", d));

    assertEquals("-2147483648", xpath.evaluate("//OCD/AD[@id='rBooleans']/@cardinality", d));
    assertEquals("-2147483648", xpath.evaluate("//OCD/AD[@id='rBytes']/@cardinality", d));
    assertEquals("-2147483648", xpath.evaluate("//OCD/AD[@id='rCharacters']/@cardinality", d));
    assertEquals("-2147483648", xpath.evaluate("//OCD/AD[@id='rShorts']/@cardinality", d));
    assertEquals("-2147483648", xpath.evaluate("//OCD/AD[@id='rInts']/@cardinality", d));
    assertEquals("-2147483648", xpath.evaluate("//OCD/AD[@id='rLongs']/@cardinality", d));
    assertEquals("-2147483648", xpath.evaluate("//OCD/AD[@id='rFloats']/@cardinality", d));
    assertEquals("-2147483648", xpath.evaluate("//OCD/AD[@id='rDoubles']/@cardinality", d));
    assertEquals("-2147483648", xpath.evaluate("//OCD/AD[@id='rStrings']/@cardinality", d));
    assertEquals("-2147483648", xpath.evaluate("//OCD/AD[@id='rURIs']/@cardinality", d));
  }