OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

ubl-dev message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [ubl-dev] Re: Perl UBL validator - example


David,

That's a good idea.

I have to run some more tests on my UBL order output module
over the weekend and when that is done I'll generate some,
check them, and send them over.

Personally, I'm not sure how I can see self-validation of
a document working in a production business environment.

Normally, wouldn't a transaction document be validated on
a set of absolute business criteria set by the receipient?
 
ie for a PO, must have at least one line item, must have a
sender account identifier etc. Must have correct prices
or no prices at all etc etc..

All these things are business rules and are absolute
for the specific businesses involved. I wasn't able to
see where CAM was able to provide this level of
functionality.

David

Quoting David RR Webber <david@drrw.info>:

> David,
> 
> Ok - I read fluent Perl ; -)
> 
> If you send me a sample XML order instance I'll send you the equivalent CAM
> template - you'll be amazed how close this is to your Perl code - but
> instead
> of hard wiring it - you can write XML to do it with - exact same way you are
> doing - with the XPath statements.
> 
> 
> That way at least you'll have a point of reference.
> 
> Cheers, DW.
> =============================================================
> Quoting david.lyon@computergrid.net:
> 
> > David,
> > 
> > I probably understand what you are saying now.
> > 
> > For now though, I don't have the time. I just need some quick
> > and dirty tests for a production system.
> > 
> > Here's a basic example of a validator perl script to cust and 
> > paste at home. It's intended to do a very basic check of a UBL 
> > purchase order. This was the first cut and serves as an example. 
> > 
> > (how to use: install perl or use linux
> >              cut and paste into checkPO.pl
> >              check XPath and XMLParser libraries are installed) 
> >  to run: perl checkPO.pl <UBL-purchase-order-file>
> > 
> > Usual disclaimers apply.
> > 
> > ---- start
> > #/usr/bin/perl
> > #
> > # -- Computergrid UBL Purchase Order Validator
> > #    (c) Global Tradedesk Technology (Australia) Pty Limited 2004
> > # -- Free for educational use
> > #
> > use XML::XPath;
> > use XML::XPath::XMLParser;
> > 
> > print "Computergrid.net - UBL PO Document Test Script\n";
> > 
> > # -- create an object to parse the file and field XPath queries
> > my $xpath = XML::XPath->new( filename => shift @ARGV );
> > 
> > # --
> > print ".Checking Header for mandatory fields\n";
> > 
> > my @checkElems; 
> > my $FailCount = 0;
> >  
> > # -- apply the path from the command line and get back a list matches
> > #my $nodeset = $xpath->find( shift @ARGV );
> > 
> > push (@checkElems,"/Order/cat:IssueDate");
> > push (@checkElems,"/Order/cat:BuyersID");
> > push (@checkElems,"/Order/cat:SellersID");
> > push (@checkElems,"/Order/cat:LineExtensionTotalAmount");
> > push (@checkElems,"/Order/cat:LineItemCountQuantity");
> > push (@checkElems,"/Order/cat:BuyerParty/cat:SellerAssignedAccountID");
> > push (@checkElems,"/Order/cat:OrderLine\[1\]");
> > push (@checkElems,"/Order/cat:OrderLine\[1\]/cat:LineItem/cat:Quantity");
> > push
> >
>
(@checkElems,"/Order/cat:OrderLine\[1\]/cat:LineItem/cat:LineExtensionAmount");
> > push
> >
>
(@checkElems,"/Order/cat:OrderLine\[1\]/cat:LineItem/cat:Item/cat:Description");
> > push
> >
>
(@checkElems,"/Order/cat:OrderLine\[1\]/cat:LineItem/cat:Item/cat:SellersItemIdentification/cat:ID");
> > #push
> >
>
(@checkElems,"/Order/cat:OrderLine\[1\]/cat:LineItem/cat:Item/cat:BasePrice");
> > 
> > # -- Now loop through each of the elements to validate and check their
> > existance
> > foreach my $elem (@checkElems) {
> > 
> >     if ($xpath->exists($elem)){
> > 
> >         my $nodeset = $xpath->find($elem);
> >         print "  ..\[Exists\] $elem\n";
> >     } else {
> >         print "  ..\[Not Exists\] $elem \n";
> > 	$FailCount = $FailCount + 1;
> >     }
> > }
> > 
> > if ($FailCount eq 0){
> >     print "[Pass] Document passed Validatation test\n";
> > } else {
> >     print "[Fail] Document failed Validatation test with $FailCount
> > Errors\n";
> > }
> > 
> > ---- end
> > 
> > Quoting David RR Webber <david@drrw.info>:
> > 
> > > David,
> > > 
> > > The only thing I'd add to Jon's comments is - why re-invent the wheel?
> > > 
> > > OASIS already has the CAM specification in place - you are most welcome
> to
> > > integrate the concepts and techniques from that work - and there's even
> > the
> > > open source implementaton to help you.
> > > 
> > > There is certainly a perfect opportunity from the business stance to
> > create
> > > a
> > > shareware product that provides cool end-user tools to manipulate rules
> > and
> > > UBL
> > > structures and express those in CAM templates as XML...
> > > 
> > > If you look at the CAM Wizard HTML and Javascript that's in the tutorial
> > > available from the OASIS CAM site - you may get even more ideas of how
> you
> > > could embed UBL structures into an online Wizard - and then allows you
> to
> > > click
> > > and choose - and build your rules sets.  Just some ideas.
> > > 
> > > This would make a very nice shareware product that would be easy to
> > > implement
> > > IMHO.  Oh - yep - you can write it in Perl too if you want too - no
> > > objections
> > > there!
> > > 
> > > Cheers, DW.
> > > ============================================================
> > > 
> > > Quoting jon.bosak@sun.com:
> > > 
> > > > [david.lyon@computergrid.net:]
> > > > 
> > > > | We are in the middle of producing a UBL validator/testpad so we
> > > > | haven't made it publicly available yet.
> > > > | 
> > > > | It's written in Perl and does a wide variety of tests on
> > > > | documents. The basic idea is that it would be able to scrutinise a
> > > > | trading partners documents for compliance to the specifications.
> > > > | 
> > > > | Our plan is to release the tool as shareware in the next month or
> > > > | so.
> > > > 
> > > > David,
> > > > 
> > > > This is exactly the kind of tool we need to make UBL practical,
> > > > and I'm glad to see the ubl-dev list beginning to function as a
> > > > place for sharing this sort of information.  As your examples
> > > > show, real-life applications need to do a lot of "business
> > > > validation" beyond the "schema validation" provided by the UBL
> > > > schemas.  It will be interesting to see the various approaches
> > > > that emerge to accomplish this.
> > > > 
> > > > | If anything, UBL needs way more tools from way more people than
> > > > | it has.
> > > > 
> > > > I completely agree.  The more, the better.
> > > > 
> > > > | and I sometimes get the impression that there is a lot of
> > > > | negative encouragement given to anybody outside of the
> > > > | oasis banner, as if to say, leave it to the big boys, we'll
> > > > | take care of it. Whatever....
> > > > 
> > > > Please don't take the comments of any particular OASIS participant
> > > > as reflecting the organization as a whole.  OASIS has one of the
> > > > least hierarchical organizational structures of any major
> > > > standards body, and no chair of an OASIS TC speaks for any other
> > > > TC.  I can assure you as the chair of the UBL TC that we are
> > > > wholeheartedly supportive of efforts such as yours, and I applaud
> > > > the shareware approach you're planning to adopt for distribution
> > > > of your product.
> > > > 
> > > > | UBL and ebxml is struggling... can't see why....
> > > > 
> > > > UBL and ebXML are both continuing to steadily gain traction in the
> > > > face of heavy opposition from certain Very Large American Software
> > > > Companies.  Those of us who were privileged to watch the early
> > > > "grass roots" stages of Web adoption can see some basic
> > > > similarities here.  Just as in the case of the web, homegrown
> > > > products such as yours will play an essential role in deploying
> > > > these user-oriented technologies.  Keep up the good work!
> > > > 
> > > > Jon
> > > > 
> > > > 
> > > 
> > > 
> > > http://drrw.net
> > > 
> > 
> > 
> > 
> > 
> > -------------------------------------------------------
> > 
> > 
> 
> 
> http://drrw.net
> 




-------------------------------------------------------



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]