Code Monkey home page Code Monkey logo

opentranssharp's People

Contributors

pedropauloreis avatar warappa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

opentranssharp's Issues

Flaky Tests Due To Build Acceleration

Some UDX tests fail (on my machine) every second time as there seems to be multiple initialized instances of cached SchemaSet depending on the AppDomain of the executing test.
If it is initialized by a test with UDXs defined, then validation works. If it was initialized without it those UDX tests fail.

Invalid XML Mapping for ClassificationGroupFeatureTemplate.Values

Reported by @pedropauloreis

The parameter object "List Values" was defined with the XML attribute [BMEXmlElement("FT_VALUES")] while it should be defined with [BMEXmlElement("FT_VALUES")] and [BMEXmlArrayItem("FT_VALUE")].
This error causes a validation error after serializing an XML to BMEcatDocument and makes it impossible to access the values of this FT_VALUES list inside the CLASSIFICATION_GROUP_FEATURE_TEMPLATE object.

Only Support Officially Supported .NET Versions

To simplify the development, this project will switch to supporting only officially supported .NET versions.
.NET Core 3.1 and .NET 5 are out of support for some time now and it's advised anyway to update to supported .NET versions.

As of today this means this library only supports

  • .NET 6
  • .NET 7
  • .NET 8

As an extra, I leave .NET Standard 2.0 where it makes sense.

optional <ORDER_DATE> causes an error in validation when not present

Sample XML:

<CUSTOMER_ORDER_REFERENCE>
<ORDER_ID>a</ORDER_ID>
</CUSTOMER_ORDER_REFERENCE>

deserializes fine as it should but document.Validate(serializer) reports an error:

"/ORDER/ORDER_HEADER[1]/ORDER_INFO[1]/CUSTOMER_ORDER_REFERENCE[1]/ORDER_DATE[1]": [
"If the 'nillable' attribute is false in the schema, the 'xsi:nil' attribute must not be present in the instance.",
"The 'http://www.opentrans.org/XMLSchema/2.1:ORDER_DATE' element is invalid - The value '' is invalid according to its datatype 'http://www.bmecat.org/bmecat/2005:dtDATETIME' - The Pattern constraint failed."]

DOCTYPE Causes Exception

An XML with an DOCTYPE causes an exception.

Sample XML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE BMECAT SYSTEM "http://www.eclass.eu/static/eClassXML/2.0/bmecat/bmecat_2005_tnc.dtd">
<BMECAT version="2005" xmlns="http://www.bmecat.org/bmecat/2005">
...

Exception

System.Xml.XmlException: 'For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.'

ORDER Document type EMAIL differences

Hello @warappa ,

I've noticed 2 differences between handling email information in the library and the OpenTrans specification.

The differences are in the ORDER Document Type and its ADDRESS information.

According to the documentation, the ADDRESS -> CONTACT_DETAILS -> EMAILS field can be a list of email addresses.
Int he source code, in the \src\OpenTransSharp\Types\OpenTransContactDetails.cs the property is defined like this:

        /// <summary>
        /// (optional) E-mail addresses<br/>
        /// <br/>
        /// List of e-mail addresses.<br/>
        /// <br/>
        /// XML-namespace: BMECAT
        /// </summary>
        [BMEXmlElement("EMAILS")]
        public global::BMEcatSharp.Email? Email { get; set; }

The comment states it is a list of emails, but the property is just one email.

The 2nd difference is in the EMAIL field on the ADDRESS. From the documentation and examining the official XSD files, we see that the definition is the same as the EMAILS on the CONTACT_DETAILS, but in the code, we can only add a single email address.

Would you be willing to consider changing the field logic according to the docs to the library? I could help with a PR with the changes if you agree with the field logic update and would be willing to accept them.

BMEcat version 5.0.1 support

Hi,

it's a very impressive package that helps to build the needed files.
However the BMEcat ETIM version has been improved and it's on 5.0.1.

Is there a plan to update the models or is there a way to adjust that in current implementation but I'm missing the documentation maybe.

E.g.: New transaction mode: T_NEW_PRODUCTDATA, etc.

Thanks.

Email fields XML serialization

First I would like to thank you for accepting my bug report #14 .

I've installed the new package and updated my code, however, I've noticed that one of my tests is now failing.

When populating the email field, the objects are populated correctly, however, the final serialized XML doesn't contain the value unless we access it first. On first look, it looks like something with the Lazy evaluation.

Here's a short snippet. In case I un-comment the var x = ... line, the code works fine and the Does.Contain assertion is successful. But in case we don't evaluate the emails and just call serialize, the final XML doesn't contain that information.

// Here the address has email set to "[email protected]"
var otAddress = new OpenTransSharp.Address
        {
           ...
            Emails = addressInformation.ContactInfo.Emails != null ? addressInformation.ContactInfo.Emails.Select(s => new Email
            {
                EmailAddress = s
            }).ToList() : null,
            ...
        };


 // var x = otAddress.Emails.First().EmailAddress;

 var options = new OpenTransXmlSerializerOptions();
 var serializerFactory = new OpenTransXmlSerializerFactory(options);

 var serializer = serializerFactory.Create<OpenTransSharp.Address>();

 string serializedContent = serializer.Serialize(otAddress);

 Assert.Multiple(() =>
 {
     Assert.That(serializedContent, Is.Not.Null);
     Assert.That(serializedContent, Does.Contain("[email protected]"));
 });

wrong BMEcatDocument namespace?

Hello @warappa ,

In your code I can see you use:

[XmlRoot("BMECAT", Namespace = "http://www.bmecat.org/bmecat/2005")]
public class BMEcatDocument

This does not work with my BMECAT, because it uses:
<BMECAT xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2005" xmlns="http://www.bmecat.org/bmecat/2005fd">

You see, it has the ending 2005fd in the namespace.

When I change it in the XML to 2005 at the end it is working.

Can I get this working somehow by using any parameter or option?

My code looks like this:

        public static BMEcatDocument GetBMEcatDocument(
            this Stream stream, 
            out string errorMessage, 
            BMEcatXmlSerializerOptions options = null)
            
        {
            // init return values
            BMEcatDocument theDoc = null;
            errorMessage = null;

            // get serializer factory
            BMEcatXmlSerializerFactory fac = new BMEcatXmlSerializerFactory(
                options ?? new BMEcatXmlSerializerOptions 
                {
                    // add default options if needed
                });

            // deserialize and validate the document
            try
            {
                XmlSerializer serializer = fac.Create<BMEcatDocument>();
                theDoc = serializer.Deserialize<BMEcatDocument>(stream);
                theDoc.EnsureValid(serializer);
            }
            catch (Exception exc)
            {
                errorMessage = exc.Message;
            }

            return theDoc;
        }
    }

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.