Re: Indentation CUSTOM_XSLT_FILENAME

17 views
Skip to first unread message

Fady

unread,
Apr 8, 2013, 2:27:07 AM4/8/13
to legsta...@googlegroups.com
I use the classes that come with the JDK.

The relevant code in com.legstar.cob2xsd.Cob2Xsd is:

            TransformerFactory tFactory = TransformerFactory.newInstance();
            try {
                tFactory.setAttribute("indent-number", "4");
            } catch (IllegalArgumentException e) {
                _log.warn("Unable to set indent-number on transfomer factory",
                        e);
            }
            StringWriter writer = new StringWriter();
            Source source = new DOMSource(xsd.getAllSchemas()[0]);
            Result result = new StreamResult(writer);
            Transformer transformer;
            String xsltFileName = getModel().getCustomXsltFileName();
            if (xsltFileName == null || xsltFileName.trim().length() == 0) {
                transformer = tFactory.newTransformer();
            } else {
                Source xsltSource = new StreamSource(new File(xsltFileName));
                transformer = tFactory.newTransformer(xsltSource);
            }
            transformer.setOutputProperty(OutputKeys.ENCODING, getModel()
                    .getXsdEncoding());
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer
                    .setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
            transformer.setOutputProperty(OutputKeys.STANDALONE, "no");

            transformer.transform(source, result);
            writer.flush();

As you can see, there is an attempt at setting indentation programmatically. Maybe that is interfering with your output directive?


Michael Igler

unread,
Apr 8, 2013, 3:23:27 AM4/8/13
to legsta...@googlegroups.com
When I remove the CUSTOM_XSLT_FILENAME parameter then the generated XSD files are well indentated. When removing the element

<xsl:output method="xml" indent="yes" />

completely from my XSLT script, then it works. It seems that this tag confuses the XSLT processor. Thanx for you help.
Reply all
Reply to author
Forward
0 new messages