Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-573

The values of XML configuration keys having namespace prefix are null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.10
    • 2.0
    • Expression engine
    • None

    Description

      Consider such snippet:

      public void testElementWithNameSpace() throws Exception {
          String xml =
                  "<Config>\n" +
                  "<dsig:Transforms xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\">\n" +
                  "  <dsig:Transform Algorithm=\"http://www.w3.org/TR/1999/REC-xpath-19991116\">\n" +
                  "    <dsig:XPath xmlns:ietf=\"http://www.ietf.org\" xmlns:pl=\"http://test.test\">self::pl:policy1</dsig:XPath>\n" +
                  "  </dsig:Transform>\n" +
                  "  <dsig:Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/>\n" +
                  "</dsig:Transforms>" +
                  "</Config>";
          final XMLConfiguration config = new XMLConfiguration();
          config.setAttributeSplittingDisabled(true);
          config.setDelimiterParsingDisabled(true);
          config.setExpressionEngine(new XPathExpressionEngine());
      
          config.load(new StringReader(xml));
          System.out.println(ConfigurationUtils.toString(config));
      }
      

      It prints all keys as null:

      dsig:Transforms/dsig:Transform/dsig:XPath=null
      dsig:Transforms/dsig:Transform/dsig:XPath/@xmlns:ietf=null
      dsig:Transforms/dsig:Transform/dsig:XPath/@xmlns:pl=null
      dsig:Transforms/dsig:Transform/@Algorithm=null
      dsig:Transforms/@xmlns:dsig=null
      

      Without XPathExpressionEngine set it prints correct values:

      dsig:Transforms.dsig:Transform.dsig:XPath=self::pl:policy1
      dsig:Transforms.dsig:Transform.dsig:XPath[@xmlns:ietf]=http://www.ietf.org
      dsig:Transforms.dsig:Transform.dsig:XPath[@xmlns:pl]=http://test.test
      dsig:Transforms.dsig:Transform[@Algorithm]=[http://www.w3.org/TR/1999/REC-xpath-19991116, http://www.w3.org/TR/2001/REC-xml-c14n-20010315]
      dsig:Transforms[@xmlns:dsig]=http://www.w3.org/2000/09/xmldsig#
      

      JXPath 1.3 version dependecy was used.
      Am I missing something?

      Attachments

        Activity

          People

            Unassigned Unassigned
            abyss Petras
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: