Examples of XMLParserException


Examples of nexj.core.util.XMLParserException

         m_parser.parse(in, msg2);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         XMLParserException cause = (XMLParserException)ex.getCause();

         assertEquals("err.xml.parser", cause.getErrorCode());
      }

      // Valid sub-message (parsed through inheritance)
      in = new StringInput(
         "<ns:schema1 xsi:type=\"ns:Schema2Type\"" +
            " xmlns:ns=\"urn:com.nexjsystems:ns:test:inherit:schema1\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<a>2Hi</a>" +
            "<b>2there!</b>" +
         "</ns:schema1>");

      root = m_parser.parse(in, msg1);
      assertEquals("XML_Inherit_Schema2", root.getClassName());
      assertEquals("2Hi", root.getValue("a"));
      assertEquals("2there!", root.getValue("b"));

      // Invalid sub-message (parsed through inheritance)
      in = new StringInput(
         "<ns:schema1 xsi:type=\"ns:Schema2Type\"" +
            " xmlns:ns=\"urn:com.nexjsystems:ns:test:inherit:schema1\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<a>Hi</a>" +
            "<b>there!</b>" +
            "<c>bye</c>" +
         "</ns:schema1>");

      try
      {
         m_parser.parse(in, msg1);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         XMLParserException cause = (XMLParserException)ex.getCause();

         assertEquals("err.xml.parser", cause.getErrorCode());
      }

      // Valid sub-sub-message in different schema (direct)
      in = new StringInput(
         "<ns3:schema3" +
            " xmlns:ns=\"urn:com.nexjsystems:ns:test:inherit:schema1\"" +
            " xmlns:ns3=\"urn:com.nexjsystems:ns:test:inherit:schema3\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<a>3Hi</a>" +
            "<b>3there!</b>" +
            "<cReal>bye</cReal>" +
         "</ns3:schema3>");

      root = m_parser.parse(in, msg3);
      assertEquals("XML_Inherit_Schema3", root.getClassName());
      assertEquals("3Hi", root.getValue("a"));
      assertEquals("3there!", root.getValue("b"));
      assertEquals("bye", root.getValue("cReal"));

      // Invalid sub-sub-message in different schema (direct)
      in = new StringInput(
         "<ns3:schema3" +
            " xmlns:ns=\"urn:com.nexjsystems:ns:test:inherit:schema1\"" +
            " xmlns:ns3=\"urn:com.nexjsystems:ns:test:inherit:schema3\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<a>3Hi</a>" +
            "<b>3there!</b>" +
            "<cReal>bye</cReal>" +
            "<x>bad</x>" +
         "</ns3:schema3>");

      try
      {
         m_parser.parse(in, msg3);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         XMLParserException cause = (XMLParserException)ex.getCause();

         assertEquals("err.xml.parser", cause.getErrorCode());
      }

      // Valid sub-sub-message in different schema (inheritance)
      in = new StringInput(
         "<ns:schema1 xsi:type=\"ns3:Schema3Type\"" +
            " xmlns:ns=\"urn:com.nexjsystems:ns:test:inherit:schema1\"" +
            " xmlns:ns3=\"urn:com.nexjsystems:ns:test:inherit:schema3\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<a>4Hi</a>" +
            "<b>4there!</b>" +
            "<cReal>2bye</cReal>" +
         "</ns:schema1>");

      root = m_parser.parse(in, msg1);
      assertEquals("XML_Inherit_Schema3", root.getClassName());
      assertEquals("4Hi", root.getValue("a"));
      assertEquals("4there!", root.getValue("b"));
      assertEquals("2bye", root.getValue("cReal"));

      // Invalid sub-sub-message in different schema (inheritance)
      in = new StringInput(
         "<ns:schema1 xsi:type=\"ns3:Schema3Type\"" +
            " xmlns:ns=\"urn:com.nexjsystems:ns:test:inherit:schema1\"" +
            " xmlns:ns3=\"urn:com.nexjsystems:ns:test:inherit:schema3\"" +
            " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
            "<a>4Hi</a>" +
            "<b>4there!</b>" +
            "<cReal>2bye</cReal>" +
            "<x>bad</x>" +
         "</ns:schema1>");

      try
      {
         m_parser.parse(in, msg1);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         XMLParserException cause = (XMLParserException)ex.getCause();

         assertEquals("err.xml.parser", cause.getErrorCode());
      }
   }
View Full Code Here

Examples of org.mybatis.generator.exception.XMLParserException

      Document document = null;
      try {
        document = builder.parse(inputSource);
      } catch (SAXParseException e) {
        throw new XMLParserException(parseErrors);
      } catch (SAXException e) {
        if (e.getException() == null) {
          parseErrors.add(e.getMessage());
        } else {
          parseErrors.add(e.getException().getMessage());
        }
      }

      if (parseErrors.size() > 0) {
        throw new XMLParserException(parseErrors);
      }

      Configuration config;
      Element rootNode = document.getDocumentElement();
      DocumentType docType = document.getDoctype();
      if (rootNode.getNodeType() == Node.ELEMENT_NODE
          && docType.getPublicId().equals(XmlConstants.IBATOR_CONFIG_PUBLIC_ID)) {
        config = parseIbatorConfiguration(rootNode);
      } else if (rootNode.getNodeType() == Node.ELEMENT_NODE
          && docType.getPublicId().equals(XmlConstants.MYBATIS_GENERATOR_CONFIG_PUBLIC_ID)) {
        config = parseMyBatisGeneratorConfiguration(rootNode);
      } else {
        throw new XMLParserException(getString("RuntimeError.5")); //$NON-NLS-1$
      }

      if (parseErrors.size() > 0) {
        throw new XMLParserException(parseErrors);
      }

      return config;
    } catch (ParserConfigurationException e) {
      parseErrors.add(e.getMessage());
      throw new XMLParserException(parseErrors);
    }
  }
View Full Code Here

Examples of org.mybatis.generator.exception.XMLParserException

    Properties attributes = parseAttributes(node);
    String resource = attributes.getProperty("resource"); //$NON-NLS-1$
    String url = attributes.getProperty("url"); //$NON-NLS-1$

    if (!stringHasValue(resource) && !stringHasValue(url)) {
      throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
    }

    if (stringHasValue(resource) && stringHasValue(url)) {
      throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
    }

    URL resourceUrl;

    try {
      if (stringHasValue(resource)) {
        resourceUrl = Thread.currentThread().getContextClassLoader().getResource(resource);
        if (resourceUrl == null) {
          throw new XMLParserException(getString("RuntimeError.15", resource)); //$NON-NLS-1$
        }
      } else {
        resourceUrl = new URL(url);
      }

      InputStream inputStream = resourceUrl.openConnection().getInputStream();

      properties.load(inputStream);
      inputStream.close();
    } catch (IOException e) {
      if (stringHasValue(resource)) {
        throw new XMLParserException(getString("RuntimeError.16", resource)); //$NON-NLS-1$
      } else {
        throw new XMLParserException(getString("RuntimeError.17", url)); //$NON-NLS-1$
      }
    }
  }
View Full Code Here

Examples of org.mybatis.generator.exception.XMLParserException

    Properties attributes = parseAttributes(node);
    String resource = attributes.getProperty("resource"); //$NON-NLS-1$
    String url = attributes.getProperty("url"); //$NON-NLS-1$

    if (!stringHasValue(resource) && !stringHasValue(url)) {
      throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
    }

    if (stringHasValue(resource) && stringHasValue(url)) {
      throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
    }

    URL resourceUrl;

    try {
      if (stringHasValue(resource)) {
        resourceUrl = Thread.currentThread().getContextClassLoader().getResource(resource);
        if (resourceUrl == null) {
          throw new XMLParserException(getString("RuntimeError.15", resource)); //$NON-NLS-1$
        }
      } else {
        resourceUrl = new URL(url);
      }

      InputStream inputStream = resourceUrl.openConnection().getInputStream();

      properties.load(inputStream);
      inputStream.close();
    } catch (IOException e) {
      if (stringHasValue(resource)) {
        throw new XMLParserException(getString("RuntimeError.16", resource)); //$NON-NLS-1$
      } else {
        throw new XMLParserException(getString("RuntimeError.17", url)); //$NON-NLS-1$
      }
    }
  }
View Full Code Here

Examples of org.mybatis.generator.exception.XMLParserException

        String resource = attributes.getProperty("resource"); //$NON-NLS-1$
        String url = attributes.getProperty("url"); //$NON-NLS-1$

        if (!stringHasValue(resource)
                && !stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        if (stringHasValue(resource)
                && stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        URL resourceUrl;

        try {
            if (stringHasValue(resource)) {
                resourceUrl = ObjectFactory.getResource(resource);
                if (resourceUrl == null) {
                    throw new XMLParserException(getString(
                            "RuntimeError.15", resource)); //$NON-NLS-1$
                }
            } else {
                resourceUrl = new URL(url);
            }

            InputStream inputStream = resourceUrl.openConnection()
                    .getInputStream();

            properties.load(inputStream);
            inputStream.close();
        } catch (IOException e) {
            if (stringHasValue(resource)) {
                throw new XMLParserException(getString(
                        "RuntimeError.16", resource)); //$NON-NLS-1$
            } else {
                throw new XMLParserException(getString(
                        "RuntimeError.17", url)); //$NON-NLS-1$
            }
        }
    }
View Full Code Here

Examples of org.mybatis.generator.exception.XMLParserException

        String resource = attributes.getProperty("resource"); //$NON-NLS-1$
        String url = attributes.getProperty("url"); //$NON-NLS-1$

        if (!stringHasValue(resource)
                && !stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        if (stringHasValue(resource)
                && stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        URL resourceUrl;

        try {
            if (stringHasValue(resource)) {
                resourceUrl = ObjectFactory.getResource(resource);
                if (resourceUrl == null) {
                    throw new XMLParserException(getString(
                            "RuntimeError.15", resource)); //$NON-NLS-1$
                }
            } else {
                resourceUrl = new URL(url);
            }

            InputStream inputStream = resourceUrl.openConnection()
                    .getInputStream();

            properties.load(inputStream);
            inputStream.close();
        } catch (IOException e) {
            if (stringHasValue(resource)) {
                throw new XMLParserException(getString(
                        "RuntimeError.16", resource)); //$NON-NLS-1$
            } else {
                throw new XMLParserException(getString(
                        "RuntimeError.17", url)); //$NON-NLS-1$
            }
        }
    }
View Full Code Here

Examples of org.mybatis.generator.exception.XMLParserException

            Document document = null;
            try {
                document = builder.parse(inputSource);
            } catch (SAXParseException e) {
                throw new XMLParserException(parseErrors);
            } catch (SAXException e) {
                if (e.getException() == null) {
                    parseErrors.add(e.getMessage());
                } else {
                    parseErrors.add(e.getException().getMessage());
                }
            }

            if (parseErrors.size() > 0) {
                throw new XMLParserException(parseErrors);
            }

            Configuration config;
            Element rootNode = document.getDocumentElement();
            DocumentType docType = document.getDoctype();
            if (rootNode.getNodeType() == Node.ELEMENT_NODE
                    && docType.getPublicId().equals(
                            XmlConstants.IBATOR_CONFIG_PUBLIC_ID)) {
                config = parseIbatorConfiguration(rootNode);
            } else if (rootNode.getNodeType() == Node.ELEMENT_NODE
                    && docType.getPublicId().equals(
                            XmlConstants.MYBATIS_GENERATOR_CONFIG_PUBLIC_ID)) {
                config = parseMyBatisGeneratorConfiguration(rootNode);
            } else {
                throw new XMLParserException(getString("RuntimeError.5")); //$NON-NLS-1$
            }

            if (parseErrors.size() > 0) {
                throw new XMLParserException(parseErrors);
            }

            return config;
        } catch (ParserConfigurationException e) {
            parseErrors.add(e.getMessage());
            throw new XMLParserException(parseErrors);
        }
    }
View Full Code Here

Examples of org.mybatis.generator.exception.XMLParserException

        String resource = attributes.getProperty("resource"); //$NON-NLS-1$
        String url = attributes.getProperty("url"); //$NON-NLS-1$

        if (!stringHasValue(resource)
                && !stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        if (stringHasValue(resource)
                && stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        URL resourceUrl;

        try {
            if (stringHasValue(resource)) {
                resourceUrl = Thread.currentThread().getContextClassLoader()
                        .getResource(resource);
                if (resourceUrl == null) {
                    throw new XMLParserException(getString(
                            "RuntimeError.15", resource)); //$NON-NLS-1$
                }
            } else {
                resourceUrl = new URL(url);
            }

            InputStream inputStream = resourceUrl.openConnection()
                    .getInputStream();

            properties.load(inputStream);
            inputStream.close();
        } catch (IOException e) {
            if (stringHasValue(resource)) {
                throw new XMLParserException(getString(
                        "RuntimeError.16", resource)); //$NON-NLS-1$
            } else {
                throw new XMLParserException(getString(
                        "RuntimeError.17", url)); //$NON-NLS-1$
            }
        }
    }
View Full Code Here

Examples of org.mybatis.generator.exception.XMLParserException

        String resource = attributes.getProperty("resource"); //$NON-NLS-1$
        String url = attributes.getProperty("url"); //$NON-NLS-1$

        if (!stringHasValue(resource)
                && !stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        if (stringHasValue(resource)
                && stringHasValue(url)) {
            throw new XMLParserException(getString("RuntimeError.14")); //$NON-NLS-1$
        }

        URL resourceUrl;

        try {
            if (stringHasValue(resource)) {
                resourceUrl = Thread.currentThread().getContextClassLoader()
                        .getResource(resource);
                if (resourceUrl == null) {
                    throw new XMLParserException(getString(
                            "RuntimeError.15", resource)); //$NON-NLS-1$
                }
            } else {
                resourceUrl = new URL(url);
            }

            InputStream inputStream = resourceUrl.openConnection()
                    .getInputStream();

            properties.load(inputStream);
            inputStream.close();
        } catch (IOException e) {
            if (stringHasValue(resource)) {
                throw new XMLParserException(getString(
                        "RuntimeError.16", resource)); //$NON-NLS-1$
            } else {
                throw new XMLParserException(getString(
                        "RuntimeError.17", url)); //$NON-NLS-1$
            }
        }
    }
View Full Code Here

Examples of org.opensaml.xml.parse.XMLParserException

                } else {
                    // Namespace couldn't be resolved from any ancestor. If the namespace prefix is null then the
                    // element is simply in the undeclared default document namespace, which is fine. If it isn't null
                    // then a namespace prefix, that hasn't properly been declared, is being used.
                    if (namespacePrefix != null) {
                        throw new XMLParserException("Unable to resolve namespace prefix " + namespacePrefix
                                + " found on element " + getNodeQName(domElement));
                    }
                }
            }
        }

        // Make sure all the attribute URIs are rooted here or have been rooted in an ancestor
        NamedNodeMap attributes = domElement.getAttributes();
        Node attributeNode;
        for (int i = 0; i < attributes.getLength(); i++) {
            namespacePrefix = null;
            namespaceURI = null;
            attributeNode = attributes.item(i);

            // Shouldn't need this check, but just to be safe, we have it
            if (attributeNode.getNodeType() != Node.ATTRIBUTE_NODE) {
                continue;
            }

            namespacePrefix = attributeNode.getPrefix();
            if (!DatatypeHelper.isEmpty(namespacePrefix)) {
                // If it's the "xmlns" prefix then it is the namespace declaration,
                // don't try to look it up and redeclare it
                if (namespacePrefix.equals(XMLConstants.XMLNS_PREFIX)
                        || namespacePrefix.equals(XMLConstants.XML_PREFIX)) {
                    continue;
                }

                // check to see if the namespace for the prefix has already been defined within the XML fragment
                namespaceURI = lookupNamespaceURI(domElement, upperNamespaceSearchBound, namespacePrefix);
                if (namespaceURI == null) {
                    namespaceURI = lookupNamespaceURI(upperNamespaceSearchBound, null, namespacePrefix);
                    if (namespaceURI == null) {
                        throw new XMLParserException("Unable to resolve namespace prefix " + namespacePrefix
                                + " found on attribute " + getNodeQName(attributeNode) + " found on element "
                                + getNodeQName(domElement));
                    }

                    appendNamespaceDeclaration(domElement, namespaceURI, namespacePrefix);
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.