MichielCM / xsd2html2xml

Generates plain HTML5 forms from XML schemas (XSDs). Transforms filled-in forms into XML.
MIT License
95 stars 42 forks source link

How to generate the HTML from XSD #27

Open akhilkhandelwal opened 5 years ago

akhilkhandelwal commented 5 years ago

Hello, Thank you for wonderful library. I was trying to generate the HTML from one of my XSD.

Following is the java program which I wrote:

`public class XSLTransform { public static void main( String [] args ) throws Exception { if ( args.length < 2 || !args[0].endsWith(".xsl") ) { System.err.println("usage: XSLTransform file.xsl file.xml"); System.exit(1); } String xslFile = args[0], xmlFile = args[1];

    TransformerFactory factory = TransformerFactory.newInstance();
    Transformer transformer = 
        factory.newTransformer( new StreamSource( xslFile ) );
    StreamSource xmlsource = new StreamSource( xmlFile );
    StreamResult output = new StreamResult( System.out );
    transformer.transform( xmlsource, output );
}

}`

And I run this program as:

java XSLTransform xsd2html2xml.xsl dynamicui-definitions.xsd.

Output:

Compiler warnings: file:///C:/xsd2html2xml-3.3/xsd2html2xml-3.3/utils/gui-attributes.xsl: line 413: Attribute 'step' outside of element. file:///C:/xsd2html2xml-3.3/xsd2html2xml-3.3/utils/gui-attributes.xsl: line 424: Attribute 'step' outside of element. file:///C:/xsd2html2xml-3.3/xsd2html2xml-3.3/utils/gui-attributes.xsl: line 435: Attribute 'step' outside of element. file:///C:/xsd2html2xml-3.3/xsd2html2xml-3.3/handlers/default-types.xsl: line 135: Attribute 'data-xsd2html2xml-primitive' outside of element. file:///C:/xsd2html2xml-3.3/xsd2html2xml-3.3/handlers/default-types.xsl: line 135: Attribute 'data-xsd2html2xml-primitive' outside of element. file:///C:/xsd2html2xml-3.3/xsd2html2xml-3.3/handlers/default-types.xsl: line 139: Attribute 'data-xsd2html2xml-description' outside of element. file:///C:/xsd2html2xml-3.3/xsd2html2xml-3.3/handlers/default-types.xsl: line 139: Attribute 'data-xsd2html2xml-description' outside of element. file:///C:/xsd2html2xml-3.3/xsd2html2xml-3.3/xsd2html2xml.xsl: line 264: Attribute 'namespace' outside of element. ERROR: 'Could not compile stylesheet' FATAL ERROR: 'file:///C:/xsd2html2xml-3.3/xsd2html2xml-3.3/utils/namespaces.xsl: line 175: Second argument to document() function must be a node-set.' :file:///C:/xsd2html2xml-3.3/xsd2html2xml-3.3/utils/namespaces.xsl: line 175: Second argument to document() function must be a node-set. Exception in thread "main" javax.xml.transform.TransformerConfigurationException: file:///C:/xsd2html2xml-3.3/xsd2html2xml-3.3/utils/namespaces.xsl: line 175: Second argument to document() function must be a node-set. at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(Unknown Source) at XSLTransform.main(XSLTransform.java:16) Caused by: file:///C:/xsd2html2xml-3.3/xsd2html2xml-3.3/utils/namespaces.xsl: line 175: Second argument to document() function must be a node-set. at com.sun.org.apache.xalan.internal.xsltc.compiler.DocumentCall.typeCheck(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.CopyOf.typeCheck(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.XslElement.typeCheck(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.If.typeCheck(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.ForEach.typeCheck(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.Template.typeCheck(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.typeCheck(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.createAST(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(Unknown Source) ... 3 more

file:///C:/xsd2html2xml-3.3/xsd2html2xml-3.3/utils/namespaces.xsl: line 175: Second argument to document() function must be a node-set. at com.sun.org.apache.xalan.internal.xsltc.compiler.DocumentCall.typeCheck(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.CopyOf.typeCheck(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.XslElement.typeCheck(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.If.typeCheck(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.ForEach.typeCheck(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.Template.typeCheck(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode.typeCheckContents(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.typeCheck(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.createAST(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(Unknown Source) at XSLTransform.main(XSLTransform.java:16)

MichielCM commented 5 years ago

Do you get the same error with another XSLT compiler, such as libxslt?

akhilkhandelwal commented 5 years ago

Have not tried that. Though I used the online tool what you have, that works fine and I am able to generate the HTML.

On Fri, Jul 12, 2019, 3:07 PM Michiel Meulendijk notifications@github.com wrote:

Do you get the same error with another XSLT compiler, such as libxslt?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MichielCM/xsd2html2xml/issues/27?email_source=notifications&email_token=AASORSIRBCUCKZLYPXTY5RLP7BGDXA5CNFSM4ICFG4UKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZZILUA#issuecomment-510821840, or mute the thread https://github.com/notifications/unsubscribe-auth/AASORSKKGKHWDPCPBSWQVWDP7BGDXANCNFSM4ICFG4UA .

akhilkhandelwal commented 5 years ago

But I want to make this work as part of my build process and need make this work either by Java/shell script.

On Fri, Jul 12, 2019, 3:25 PM Akhil khandelwal khandelwal.akhil@gmail.com wrote:

Have not tried that. Though I used the online tool what you have, that works fine and I am able to generate the HTML.

On Fri, Jul 12, 2019, 3:07 PM Michiel Meulendijk notifications@github.com wrote:

Do you get the same error with another XSLT compiler, such as libxslt?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MichielCM/xsd2html2xml/issues/27?email_source=notifications&email_token=AASORSIRBCUCKZLYPXTY5RLP7BGDXA5CNFSM4ICFG4UKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZZILUA#issuecomment-510821840, or mute the thread https://github.com/notifications/unsubscribe-auth/AASORSKKGKHWDPCPBSWQVWDP7BGDXANCNFSM4ICFG4UA .

akhilkhandelwal commented 5 years ago

If you have a script/program which can be called from command line and if you do not mind it sharing, Please share. I need to automate the generation process.

Regards, Akhil

On Fri, Jul 12, 2019 at 3:39 PM Akhil khandelwal khandelwal.akhil@gmail.com wrote:

But I want to make this work as part of my build process and need make this work either by Java/shell script.

On Fri, Jul 12, 2019, 3:25 PM Akhil khandelwal khandelwal.akhil@gmail.com wrote:

Have not tried that. Though I used the online tool what you have, that works fine and I am able to generate the HTML.

On Fri, Jul 12, 2019, 3:07 PM Michiel Meulendijk < notifications@github.com> wrote:

Do you get the same error with another XSLT compiler, such as libxslt?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MichielCM/xsd2html2xml/issues/27?email_source=notifications&email_token=AASORSIRBCUCKZLYPXTY5RLP7BGDXA5CNFSM4ICFG4UKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZZILUA#issuecomment-510821840, or mute the thread https://github.com/notifications/unsubscribe-auth/AASORSKKGKHWDPCPBSWQVWDP7BGDXANCNFSM4ICFG4UA .

-- Akhil Khandelwal Mobile-9008602942

MichielCM commented 5 years ago

Just use libxslt. You can run it from the command line on Linux or Windows with a one-liner: xsltproc -o form.html xsd2html2xml.xsl dynamicui-definitions.xsd