Giter VIP home page Giter VIP logo

Comments (4)

DGPRodrigues avatar DGPRodrigues commented on August 29, 2024

image
My Onix File

image
My Code

from onix-data.

jaerith avatar jaerith commented on August 29, 2024

First, thanks for the compliment. When people give the project a star, I'm glad to know that somebody else has found a use for it.

Now, as to the issue at hand, I'm a bit surprised, since I never thought of this use case. Honestly, I never thought about people using this project to write ONIX files. Likely, I didn't think of it since many publishers use services/software to generate their ONIX files. Of the publishers that I deal with, a popular choice is Firebrand Technologies, but I'll admit that I don't know the costs involved. But, yes, you are right - it would make sense to have an open source alternative.

Unfortunately, this project at the moment won't really be an ideal choice for writing out ONIX files, since it was just meant to ingest ONIX data. Since the ONIX standard is complicated and since there are many possible tags to use for the same data (reference tags vs. short tags), the created classes were supposed to anticipate these different scenarios for parsing, with the resulting classes having many properties. (This is the reason why you're observing so many tags in your output.) In C#, it's not exactly easy to use code for ignoring these properties upon serialization, but supposedly, something like the following could help you (though I've never actually used it):

var attributes = new System.Xml.Serialization.XmlAttributes { XmlIgnore = true };

var overrides = new System.Xml.Serialization.XmlAttributeOverrides();
overrides.Add(typeof(OnixHeader), "header", attributes);

var serializer = new System.Xml.Serialization.XmlSerializer(typeof(OnixMessage), overrides);

Perhaps one day I'll get around to working on a feature that successfully serializes these classes. It's definitely a good idea!

from onix-data.

DGPRodrigues avatar DGPRodrigues commented on August 29, 2024

Hi jaerith, thanks for the reply.

In Brazil there is a company that generates these Onix files, but with high production costs and the low quantity sold (e-book in Brazil is becoming popular now), the publisher decided to invest in its own system to generate these files.

I will check this tip you gave.

Its framework generating and consulting the Onix file, would be a perfect solution.

I will try to do something simple in your solution.

I will send news in the future.

Thank you,
Daniel

from onix-data.

jaerith avatar jaerith commented on August 29, 2024

There is of course another way, a horrible, terrible hack: you could serialize the OnixMessage class, and with regular expressions or some code, then:

1.) if you want Reference tags, remove any composite sections (like "<header>") or single lines where the tag name starts with a lowercase letter
2.) if you want Short tags, remove any composite sections (like "<Header>") or single lines where the tag name starts with a capital letter

You'll have to plan accordingly for tag values with embedded newlines. It's a horrible hack, but it might be a fast and dirty solution.

from onix-data.

Related Issues (17)

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.