{"issue":{"milestone":null,"user":{"id":1219039,"login":"ZiglioNZ","url":"https://api.github.com/users/ZiglioNZ","avatar_url":"https://secure.gravatar.com/avatar/cec004e6a38e09a4de8b54eeecdaea60?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"cec004e6a38e09a4de8b54eeecdaea60"},"created_at":"2011-12-19T02:15:25Z","title":"Added NamespacePrefixMapper property to JaxbRepresentation","updated_at":"2011-12-19T20:49:40Z","labels":[],"state":"open","id":2596285,"html_url":"https://github.com/restlet/restlet-framework-java/issues/2","closed_at":null,"pull_request":{"patch_url":"https://github.com/restlet/restlet-framework-java/pull/2.patch","html_url":"https://github.com/restlet/restlet-framework-java/pull/2","diff_url":"https://github.com/restlet/restlet-framework-java/pull/2.diff"},"body":"I've added a NamespacePrefixMapper property to JaxbRepresentation. Unfortunately I haven't been able to run the tests under org.restlet.test.ext.jaxb, I get these errors:\r\n \r\n    Setting up test org.restlet.test.ext.jaxb.JaxbBasicConverterTestCase#testObjectionToRepresentation\r\n    Unable to find a converter for this object : Sample [val=null]\r\n    Setting up test org.restlet.test.ext.jaxb.JaxbBasicConverterTestCase#testRepresentationToObject\r\n    Unable to find a converter for this representation : [application/xml,UTF-8]\r\n\r\nI use the NamespacePrefixMapper with a NameSpaceBeautifier in order to fix the output of the Java API for KML.\r\n\r\n    import de.micromata.opengis.kml.v_2_2_0.*;\r\n    import de.micromata.opengis.kml.v_2_2_0.gx.*;\r\n   \r\n    Kml kml = new Kml();\r\n    VariantInfo vi = new VariantInfo( MediaType.APPLICATION_KML );\r\n    JaxbRepresentation<Kml> re = (JaxbRepresentation<Kml>)ch.toRepresentation( kml, vi, this );\r\n    re.setNamespacePrefixMapper( new NameSpaceBeautyfier() );\r\n\r\n    private final static class NameSpaceBeautyfier extends NamespacePrefixMapper\r\n    {\r\n    /**\r\n    * Internal method!\r\n    * <p>Customizing Namespace Prefixes During Marshalling to a more readable format.</p>\r\n    * <p>The default output is like:</p>\r\n    * <pre>{@code&lt;kml ... xmlns:ns2=\"http://www.w3.org/2005/Atom\" xmlns:ns3=\"urn:oasis:names:tc:ciq:xsdschema:xAL:2.0\" xmlns:ns4=\"http://www.google.com/kml/ext/2.2\"&gt;}</pre>\r\n    * <p>is changed to:</p>\r\n    * <pre>{@code &lt;kml ... xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:xal=\"urn:oasis:names:tc:ciq:xsdschema:xAL:2.0\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\"&gt;}</pre><p>What it does:</p>\r\n    * <p>namespaceUri: http://www.w3.org/2005/Atom              prefix: atom</p><p>namespaceUri: urn:oasis:names:tc:ciq:xsdschema:xAL:2.0 prefix: xal</p><p>namespaceUri: http://www.google.com/kml/ext/2.2        prefix: gx</p><p>namespaceUri: anything else prefix: null</p>\r\n    * \r\n    */\r\n    @Override\r\n    public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {\r\n      if (namespaceUri.matches(\"http://www.w3.org/\\\\d{4}/Atom\")) {\r\n          return \"atom\";\r\n      }\r\n      if (namespaceUri.matches(\"urn:oasis:names:tc:ciq:xsdschema:xAL:.*?\")) {\r\n          return \"xal\";\r\n      }\r\n      if (namespaceUri.matches(\"http://www.google.com/kml/ext/.*?\")) {\r\n          return \"gx\";\r\n      }\r\n      return null;\r\n     }\r\n    }\r\n","number":2,"url":"https://api.github.com/repos/restlet/restlet-framework-java/issues/2","comments":2,"assignee":null},"comment":{"user":{"id":374450,"login":"jlouvel","url":"https://api.github.com/users/jlouvel","avatar_url":"https://secure.gravatar.com/avatar/765bfcdaf67b4dd5b4d3ef5277456fd5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"765bfcdaf67b4dd5b4d3ef5277456fd5"},"created_at":"2011-12-19T20:49:40Z","updated_at":"2011-12-19T20:49:40Z","id":3209293,"body":"Thanks for the contribution. Could you take into account the comments and send us the signed JCA?\r\nhttp://www.restlet.org/community/contribute\r\n\r\nWe will then pull this for Restlet 2.2.","url":"https://api.github.com/repos/restlet/restlet-framework-java/issues/comments/3209293"},"action":"created"}