chrisribal / onix-parser Goto Github PK
View Code? Open in Web Editor NEWONIX 3.0 file parser
License: MIT License
ONIX 3.0 file parser
License: MIT License
The __construct of a DateTime object fails, if the input format is just a year like "2013" in this example.
Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string (2013--T) at position 4 (-): Unexpected character in /Users/alexs/Work/onixtest/vendor/ribal/onix/src/Date.php:124
Stack trace:
#0 /Users/alexs/Work/onixtest/vendor/ribal/onix/src/Date.php(124): DateTime->__construct('2013--T')
#1 /Users/alexs/Work/onixtest/vendor/ribal/onix/src/Date.php(144): Ribal\Onix\Date->parseDate('2013')
#2 /Users/alexs/Work/onixtest/vendor/ribal/onix/src/Normalizer/DateNormalizer.php(22): Ribal\Onix\Date::parse('2013', '00')
#3 /Users/alexs/Work/onixtest/vendor/symfony/serializer/Serializer.php(196): Ribal\Onix\Normalizer\DateNormalizer->denormalize('2013', 'Ribal\\Onix\\Date', 'xml', Array)
#4 /Users/alexs/Work/onixtest/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php(477): Symfony\Component\Serializer\Serializer->denormalize('2013', 'Ribal\\Onix\\Date', 'xml', Array)
#5 /Users/alexs/Work/onixtest/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php(364): Symfony\Component\Serialize in /Users/alexs/Work/onixtest/vendor/ribal/onix/src/Date.php on line 124
It's caused by following data inside a ONIX file:
<publishingdetail>
<publishingdate><x448>11</x448><j260>05</j260><b306>2013</b306></publishingdate>
<publishingdate><x448>01</x448><j260>00</j260><b306>20131001</b306></publishingdate>
</publishingdetail>
If i add a try…catch block around the __construct, the ONIX file can be parsed without problems. I believe the correct solution is the need of parsing the date differently, inside those cryptic onix elements i think it should be 11.05.2013
Just glancing at this project for possible future use, and noticed what seems like an issue with the documentation:
// Either get the Code object and read it's code and/or value
$type = $product->getNotificationType();
$code = $code->getCode(); // "03"
$value = $code->getValue(); // "Notification confirmed on publication"
I assume the second line of code should read:
$code = $type->getCode();
Since $code was not defined prior to this line. I haven't dug into the code itself, but that strikes me as probably incorrect.
Apologies if I've misunderstood!
Hi Chris,
Thank you for merging my PR. I decided to switch back from my fork to your dev-master, however I noticed you introduced a new error during your merges. In the ProductFormFeature there are now 2 use cases at the top of the file for CodeList220 (see: https://github.com/chrisribal/onix-parser/blob/3c62367a5fad9e5404e43324d3662c64213ee8bd/src/Product/ProductFormFeature.php#LL8C37-L8C37). This causes a Fatal Compile Error so could you please fix this?
Thx,
Ward
Hi,
I don't quite know the Onix specs, but I have an Onix file to parse, and I'd like to use you lib that seems very useful.
I have an error :
[Thu Aug 26 17:29:11 2021] 127.0.0.1:59642 [500]: GET / - Uncaught Symfony\Component\Serializer\Exception\NotNormalizableValueException: The type of the "ImprintName" attribute for class "Ribal\Onix\Product\Imprint" must be one of "string" ("array" given). in /home/boris/Desktop/fel/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:478
Here is the node I have in my XML file:
<ImprintName sourcename="DILICOM" sourcetype="04">UNIV EUROPEENNE</ImprintName>
I don't know if it is the library that not manages this case or the file that I have that is not respectful of the Onix format?
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.