Giter Club home page Giter Club logo

xsd-gen's People

Contributors

fjardlabs avatar froderanders avatar montoyaedu avatar subwiz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

xsd-gen's Issues

Release plan?

Hi! I'm looking forward this library and I want to know which kind of release plan do you have for a stable version, any idea? I think some explanation on wiki or readme could help.
Thanks!

optional elements should be discovered in sibling XML nodes

the present code will not traverse sibling nodes that may have undiscovered optional nodes (minOccurs="0", xsd:choice, use="optional", etc). I would like an option to submit XML with sparse sibling nodes AND to submit multiple XML documents (each with same structure but incomplete information).

I will try to contribute this.

Detect dateTime correctly from ISO8601 formatted data

Great library - very useful :-)

Would it be possible to add a feature where the data type is inferred from the contents? For example dateTime could be accurately guessed based on a content of ISO8601 formatted data (2000-01-01T12:34:56Z).

I'm thinking a few of these in TypeInferenceUtil:

private static final Pattern P_DATE_TIME = Pattern.compile("^([\\+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T\\s]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24\\:?00)([\\.,]\\d+(?!:))?)?(\\17[0-5]\\d([\\.,]\\d+)?)?([zZ]|([\\+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?$");

This will correctly identify an ISO8601 format containing a valid date time.

Open source license

Hi @subwiz.

It looks like this repository is missing open source license reference.
This make it problematic to fork and reuse the code in big corporation projects.

According to this manifest I believe, it wasn't your intention:
https://www.wiztools.org/tenets.html

Wouldn't it make it difficult to you to add some license reference (e.g MIT) to this github repository?

Thanks a lot!

detect optional attributes.

Hello,

It would be nice to add a feature for scanning the whole xml sample in order to determine if there are optional attributes.

Error 64 on make

Hi,

by following the documentation for make, in both examples I receive an error "make: *** [/usr/local/share/XML-Schema-learner/schema-learn] Error 64".

Checking Google didn't help me. Any ideas?

Many thanks & kind regards
Mike

Why 20 digits of number it generate like long

Hello guys. here is example of why 20 digits of number. Xsd generates it like long type data
40700810256895634168
040037470
1
After using XsdGen class it outputs like this.
xsd:sequence
<xsd:element name="account" minOccurs="0" type="xsd:long"/>
<xsd:element name="branchBIC" minOccurs="0" type="xsd:int"/>
<xsd:element name="branchCode" minOccurs="0" type="xsd:int"/>
<xsd:element name="currencyIsoCode" minOccurs="0" type="xsd:normalizedString"/>
</xsd:sequence>
If you guys pay attention leading zero type is also xsd int and account which more than long maximal size also xsd:long type why not making it string guys.

Treated as datetime 12121212

Exception: cvc-datatype-valid.1.2.1: '12121212' is not a valid value for 'dateTime'.

However ->12121212 results in schema file as <xsd:element name="CusomerACCTNumber" minOccurs="0" type="xsd:dateTime"/> ?

Add support for InputStream to XsdGen

Perhaps XsdGen could be modified to take an InputStream to remove the need to use a File if this library is embedded in another app:

   private Document getDocument(InputStream is) throws ParsingException, IOException {
        Builder parser = new Builder();
        Document d = parser.build(is);
        return configureDocument(d);
    }

    private Document getDocument(File file) throws ParsingException, IOException {
        Builder parser = new Builder();
        Document d = parser.build(file);
        return configureDocument(d);
    }

    private Document configureDocument(Document d) {
        final Element rootElement = d.getRootElement();

        // output Document
        Element outRoot = new Element(xsdPrefix + ":schema", XSD_NS_URI);
        Document outDoc = new Document(outRoot);

        // setting targetNamespace
        final String nsPrefix = rootElement.getNamespacePrefix();
        final boolean hasXmlns = rootElement.getNamespaceDeclarationCount() > 0;
        if (hasXmlns || StringUtil.isNotEmpty(nsPrefix)) {
            outRoot.addAttribute(new Attribute("targetNamespace", rootElement.getNamespaceURI()));
            outRoot.addAttribute(new Attribute("elementFormDefault", "qualified"));
        }

        // adding all other namespace attributes
        for (int i = 0; i < rootElement.getNamespaceDeclarationCount(); i++) {
            final String nsPrefix2 = rootElement.getNamespacePrefix(i);
            final String nsURI = rootElement.getNamespaceURI(nsPrefix2);
            outRoot.addNamespaceDeclaration(nsPrefix, nsURI);
        }

        // adding the root element
        Element rootElementXsd = new Element(xsdPrefix + ":element", XSD_NS_URI);
        rootElementXsd.addAttribute(new Attribute("name", rootElement.getLocalName()));
        outRoot.appendChild(rootElementXsd);
        recurseGen(rootElement, rootElementXsd);
        return outDoc;
    }

    public XsdGen parse(InputStream is) throws IOException, ParseException {
        try {
            doc = getDocument(is);
            return this;
        } catch (ParsingException ex) {
            throw new ParseException(ex);
        }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.