4 Replies Latest reply on May 10, 2004 1:20 PM by cvandyck

    DOMSource Transformation

    jamescg

      Don't know exactly where to put this one.

      I have installed JBoss 3.2.3 on Windows NT 4 Service pack 6, Window sXP and also Solaris 5.8. On Solaris everything is fine but on Windows I have a problem transforming a DOMSource.

      If I have the XML



      Two


      One



      And then evaluate the XPath /wrapper/group[@name="one"] using the XPathAPI and get the node back. Using this node I create a DOMSource and then transform the node back into it XML using the code

      TransformerFactory tFactory = TransformerFactory.newInstance();
      Transformer transformer = tFactory.newTransformer();
      transformer.setOutputProperty("omit-xml-declaration", "yes");

      StringWriter sw = new StringWriter();
      StreamResult result = new StreamResult(sw);

      DOMSource source = new DOMSource(theNode);
      transformer.transform( source, result );

      nodeString = sw.getBuffer().toString();

      OnSolaris I get the xml


      Two


      but on windows I get the XML



      Two


      One



      I have installed Tomcat 4 and 5 as standalone server and the code works ok here it is only when I am using JBoss on Window that this error happens

      Anyone have any ideas ?

      Thanks

      James

        • 1. Re: DOMSource Transformation
          jamescg

          Doh!!! Need to encode the the XML

          Source XML

          <wrapper>
          <group name="one">
          <one>Two</one>
          </group>
          <group name="two">
          <two>One</two>
          </group>
          </wrapper>

          Solaris Output

          <group name="one">
          <one>Two</one>
          </group>

          Windows Output

          <wrapper>
          <group name="one">
          <one>Two</one>
          </group>
          <group name="two">
          <two>One</two>
          </group>
          </wrapper>

          • 2. Re: DOMSource Transformation
            jamescg

            Try again. Stupid forum



            Two


            One



            Solaris output


            Two


            Windows Output



            Two


            One


            • 3. Re: DOMSource Transformation
              jamescg

              I give up!!!!. Sure you can work it out.

              • 4. Re: DOMSource Transformation
                cvandyck

                try using the [ code ] ... [/ code ] tags

                It makes your code look like:

                <xml>
                 <one>two</one>
                </xml>
                


                Also, the "preview" button :)