Maven Doxia
  1. Maven Doxia
  2. DOXIA-133

default XML encoding (UTF-8) or XML encoding set in XML files is ignored: inputEncoding is used instead

    Details

    • Flags:
      Patch

      Description

      Encoding can be specified per file, in the XML header: <?xml version="1.0" encoding="xxx"?>, or defaults to UTF-8

      But DefaultSiteRenderer class always read files with inputEncoding: reader = new InputStreamReader( new FileInputStream( fullPathDoc ), context.getInputEncoding() );

      When the source file is XML (xdoc, xhtml), should use XmlReader from PLXUTILS-11 to detect the XML stream encoding instead.

      Test case included in MSITE-239, site-plugin-test14

      1. DOXIA-133_doxia.diff
        4 kB
        Hervé Boutemy
      2. DOXIA-133_doxia.diff
        6 kB
        Hervé Boutemy
      3. DOXIA-133_doxia.diff
        5 kB
        Hervé Boutemy
      4. DOXIA-133_doxia-siterenderer.diff
        3 kB
        Hervé Boutemy

        Issue Links

          Activity

          Hide
          Hervé Boutemy added a comment -

          here are 2 patches to add XML encoding detection for contents that are defined in XML: xdoc, xhtml, docbook, fml

          Show
          Hervé Boutemy added a comment - here are 2 patches to add XML encoding detection for contents that are defined in XML: xdoc, xhtml, docbook, fml
          Hide
          Hervé Boutemy added a comment -

          see http://docs.codehaus.org/display/MAVENUSER/XML+encoding for the roadmap to XML encoding support in Maven2

          Show
          Hervé Boutemy added a comment - see http://docs.codehaus.org/display/MAVENUSER/XML+encoding for the roadmap to XML encoding support in Maven2
          Hide
          Hervé Boutemy added a comment -

          re-did the patch with latest trunk revision

          Show
          Hervé Boutemy added a comment - re-did the patch with latest trunk revision
          Hide
          Hervé Boutemy added a comment -

          patch reworked after the big refactoring in revision 562838.

          Show
          Hervé Boutemy added a comment - patch reworked after the big refactoring in revision 562838.
          Hide
          Siveton Vincent added a comment -

          From an API point of view, I am not at ease with Doxia.isXmlSource( String parserId ). I propose you a better approach which sounds better for me:

          Doxia.java
          ...
              /**
               * @param parserId Identifier for the parser to use.
               * @return the parser defining for parserId.
               * @throws ParserNotFoundException if no parser could be found
               * for the given id.
               */
              Parser getParser( String parserId )
                  throws ParserNotFoundException;
          ...
          
          Parser.java
          ...
              /**
               * @return xml for xml parser, text for text parser
               */
              String getType();
          ...
          
          DefaultSiteRenderer.java
          ...
                       boolean isXml = doxia.getParser( renderingContext.getParserId() ).getType().equals("xml");
          ...
          

          Thoughts?

          Show
          Siveton Vincent added a comment - From an API point of view, I am not at ease with Doxia.isXmlSource( String parserId ). I propose you a better approach which sounds better for me: Doxia.java ... /** * @param parserId Identifier for the parser to use. * @ return the parser defining for parserId. * @ throws ParserNotFoundException if no parser could be found * for the given id. */ Parser getParser( String parserId ) throws ParserNotFoundException; ... Parser.java ... /** * @ return xml for xml parser, text for text parser */ String getType(); ... DefaultSiteRenderer.java ... boolean isXml = doxia.getParser( renderingContext.getParserId() ).getType().equals( "xml" ); ... Thoughts?
          Hide
          Hervé Boutemy added a comment -

          +1 on Doxia.getParser(String): Parser

          -0 on Parser.getType():String
          At least, there should be constants for "text" and "xml".
          I prefer Parser.isXml() because getType() seems too open for me

          Show
          Hervé Boutemy added a comment - +1 on Doxia.getParser(String): Parser -0 on Parser.getType():String At least, there should be constants for "text" and "xml". I prefer Parser.isXml() because getType() seems too open for me
          Hide
          Siveton Vincent added a comment -

          Constants was implicit for me

          IMHO isXml() is too specific for an api.

          Show
          Siveton Vincent added a comment - Constants was implicit for me IMHO isXml() is too specific for an api.
          Hide
          Hervé Boutemy added a comment -

          why not, today this attribute is used only for encoding algorithm selection, but it could be used more later: such a choice is more extensible
          then go for it

          Show
          Hervé Boutemy added a comment - why not, today this attribute is used only for encoding algorithm selection, but it could be used more later: such a choice is more extensible then go for it
          Hide
          Hervé Boutemy added a comment -

          instead of String constants, why not use int constants, which would more clearly show that not any value can be used: each value has a precise meaning in the code
          and the code could switch(parser.getType()) instead of a suite of if (parser.getType().equals(Parser.TYPE_XML)) {} else if...

          Show
          Hervé Boutemy added a comment - instead of String constants, why not use int constants, which would more clearly show that not any value can be used: each value has a precise meaning in the code and the code could switch(parser.getType()) instead of a suite of if (parser.getType().equals(Parser.TYPE_XML)) {} else if ...
          Hide
          Siveton Vincent added a comment -

          Patch applied with modifications discussed there.
          Thanks again Herve.

          Show
          Siveton Vincent added a comment - Patch applied with modifications discussed there. Thanks again Herve.

            People

            • Assignee:
              Siveton Vincent
              Reporter:
              Hervé Boutemy
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development