warappa / opentranssharp Goto Github PK
View Code? Open in Web Editor NEWRead/edit/write/validate BMEcat® and openTRANS® xml files.
License: Mozilla Public License 2.0
Read/edit/write/validate BMEcat® and openTRANS® xml files.
License: Mozilla Public License 2.0
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.
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.
In ProductTypeValues.cs
"Service" is misspelled.
Currently, OpenTransSharp loads the content into the models and then validates. But sometimes even this is not possible.
Therefore the original content should be validated directly.
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
As an extra, I leave .NET Standard 2.0 where it makes sense.
.NET Core 2.1 has gone out of support. To reduce maintenance effort, support is dropped.
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."]
As .NET 6 was released a while ago, add proper support for .NET 6.
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.'
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.
According to the spec https://a.storyblok.com/f/104752/x/bef34fe816/bmecat_2005_en.pdf it should be a multiple field.
I have an BMEcat XML that uses multiple languages and it does not work. It just takes the first language in the XML.
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.
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]"));
});
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;
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.