From madcityzen at gmail.com Tue Jan 13 20:31:46 2015 From: madcityzen at gmail.com (Doug Bell) Date: Tue, 13 Jan 2015 22:31:46 -0600 Subject: [Chicago-talk] January Announcements - Introduction to Mojolicious, Travelling Meetings Message-ID: <5CAF767E-A2C4-4252-A7A8-83747FEBE160@gmail.com> Happy New Year, Chicago Perlers! This month, Joel Berger is giving an introduction to the Mojolicious web framework (http://mojolicio.us ). The presentation itself is a Mojolicious webapp, hosted on Heroku: http://mojolicious-introduction.herokuapp.com . RSVP for the presentation on the Meetup: http://www.meetup.com/ChicagoPM/events/219629915/ For 2015, we want to expand the reach of Chicago.PM, and make it easier to join us for events. To that end, we're looking for businesses in the Chicagoland area who would like to host meetings. See the thread on our Meetup discussion page for details: http://www.meetup.com/ChicagoPM/messages/boards/thread/48618307 Here's to a productive and fun year! Doug Bell madcityzen at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From me at heyjay.com Thu Jan 22 21:12:06 2015 From: me at heyjay.com (Jay Strauss) Date: Thu, 22 Jan 2015 23:12:06 -0600 Subject: [Chicago-talk] Navigating an XSD Message-ID: Hi, I have an XSD document like below. I've been googling and cpan-ing, but can't find what I need (i know there are lots of XML packages), and I don't know how to parse it using regexs (reliably). I just want to read in this XSD and navigate it like a perl structure, and extract field values like: Field:ABS.1 Item:1514 Type:XCN Table:HL70010 LongName:Discharge Care Provider Field:ABS.2 ... Can anyone recommend a module or a method? Thanks Jay Discharge Care Provider 1514 XCN HL70010 Discharge Care Provider Transfer Medical Service Code 1515 CE HL70069 Transfer Medical Service Code -------------- next part -------------- An HTML attachment was scrubbed... URL: From joel.a.berger at gmail.com Fri Jan 23 04:56:17 2015 From: joel.a.berger at gmail.com (Joel Berger) Date: Fri, 23 Jan 2015 06:56:17 -0600 Subject: [Chicago-talk] Navigating an XSD In-Reply-To: References: Message-ID: I am personal partial to Mojo::DOM though it does not have any actual XSD handling, it does xml just fine. That said, I would read through Matt Trout's recommendations here: http://shadow.cat/blog/matt-s-trout/mstpan-3/ Joel On Jan 22, 2015 11:13 PM, "Jay Strauss" wrote: > Hi, > > I have an XSD document like below. I've been googling and cpan-ing, but > can't find what I need (i know there are lots of XML packages), and I don't > know how to parse it using regexs (reliably). I just want to read in this > XSD and navigate it like a perl structure, and extract field values like: > > Field:ABS.1 > Item:1514 > Type:XCN > Table:HL70010 > LongName:Discharge Care Provider > > Field:ABS.2 > ... > > > Can anyone recommend a module or a method? > > Thanks > Jay > > > > > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns="urn:hl7-org:v2xml" > xmlns:hl7="urn:com.sun:encoder-hl7-1.0" > targetNamespace="urn:hl7-org:v2xml" xmlns:jaxb=" > http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"> > > > > > > > namespace="urn:com.sun:encoder-hl7-1.0" style="hl7encoder-1.0"/> > > > > > > > > > > > > > Discharge Care > Provider > > 1514 > XCN > HL70010 > Discharge Care Provider > > > > > > > > > > > > > > > > > > > Transfer Medical Service > Code > > 1515 > CE > HL70069 > Transfer Medical Service Code > > > > > > > > > > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jtk at depaul.edu Fri Jan 23 06:23:24 2015 From: jtk at depaul.edu (John Kristoff) Date: Fri, 23 Jan 2015 14:23:24 +0000 Subject: [Chicago-talk] Navigating an XSD In-Reply-To: <65bbf043f2574b1996cc58b114ae28d0@XCASPRD01-DFT.dpu.depaul.edu> References: <65bbf043f2574b1996cc58b114ae28d0@XCASPRD01-DFT.dpu.depaul.edu> Message-ID: <20150123142324.GA10434@aharp.iorc.depaul.edu> On Fri, Jan 23, 2015 at 05:12:06AM +0000, Jay Strauss wrote: > I have an XSD document like below. I've been googling and cpan-ing, > but can't find what I need (i know there are lots of XML packages), > and I don't know how to parse it using regexs (reliably). I just want > to read in this XSD and navigate it like a perl structure, and extract > field values like: [...] > Can anyone recommend a module or a method? Hi Jay. I have found some success using XML::Twig and XML::Writer for reading and writing respectively, for relatively simple, but large XML files. With XML::Twig, you can give it handlers based on blocks, for instance, you're interested in. For example: my $t = XML::Twig->new( twig_handlers => { 'person' => \§ion, }, ); $t->parsefile($xmlfile); sub section { my ( $t, $section ) = @_; # interested in a few elements within this section do_something_with( $section->first_child_text('birthdate') ); do_somethingelse_with( $section->first_child_text('ssn') ); # # ... # do not need that element again $section->purge; return; } See if that might work for you. John From me at heyjay.com Fri Jan 23 06:45:17 2015 From: me at heyjay.com (Jay Strauss) Date: Fri, 23 Jan 2015 08:45:17 -0600 Subject: [Chicago-talk] Navigating an XSD In-Reply-To: References: Message-ID: <1181A9E3-07A5-46DC-BD76-B13F07E350CD@heyjay.com> Thanks Joel, installing mojo::Dom as I type Sent from my iPhone > On Jan 23, 2015, at 6:56 AM, Joel Berger wrote: > > I am personal partial to Mojo::DOM though it does not have any actual XSD handling, it does xml just fine. That said, I would read through Matt Trout's recommendations here: http://shadow.cat/blog/matt-s-trout/mstpan-3/ > > Joel > >> On Jan 22, 2015 11:13 PM, "Jay Strauss" wrote: >> Hi, >> >> I have an XSD document like below. I've been googling and cpan-ing, but can't find what I need (i know there are lots of XML packages), and I don't know how to parse it using regexs (reliably). I just want to read in this XSD and navigate it like a perl structure, and extract field values like: >> >> Field:ABS.1 >> Item:1514 >> Type:XCN >> Table:HL70010 >> LongName:Discharge Care Provider >> >> Field:ABS.2 >> ... >> >> >> Can anyone recommend a module or a method? >> >> Thanks >> Jay >> >> >> >> >> > xmlns:xsd="http://www.w3.org/2001/XMLSchema" >> xmlns="urn:hl7-org:v2xml" >> xmlns:hl7="urn:com.sun:encoder-hl7-1.0" >> targetNamespace="urn:hl7-org:v2xml" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> Discharge Care Provider >> >> 1514 >> XCN >> HL70010 >> Discharge Care Provider >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> Transfer Medical Service Code >> >> 1515 >> CE >> HL70069 >> Transfer Medical Service Code >> >> >> >> >> >> >> >> >> >> >> _______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> http://mail.pm.org/mailman/listinfo/chicago-talk > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk -------------- next part -------------- An HTML attachment was scrubbed... URL: From me at heyjay.com Fri Jan 23 06:45:58 2015 From: me at heyjay.com (Jay Strauss) Date: Fri, 23 Jan 2015 08:45:58 -0600 Subject: [Chicago-talk] Navigating an XSD In-Reply-To: <20150123142324.GA10434@aharp.iorc.depaul.edu> References: <65bbf043f2574b1996cc58b114ae28d0@XCASPRD01-DFT.dpu.depaul.edu> <20150123142324.GA10434@aharp.iorc.depaul.edu> Message-ID: Hi john thanks, right now I'm going to try mojo::Dom and see how that goes Sent from my iPhone > On Jan 23, 2015, at 8:23 AM, John Kristoff wrote: > >> On Fri, Jan 23, 2015 at 05:12:06AM +0000, Jay Strauss wrote: >> I have an XSD document like below. I've been googling and cpan-ing, >> but can't find what I need (i know there are lots of XML packages), >> and I don't know how to parse it using regexs (reliably). I just want >> to read in this XSD and navigate it like a perl structure, and extract >> field values like: > [...] >> Can anyone recommend a module or a method? > > Hi Jay. I have found some success using XML::Twig and XML::Writer for reading > and writing respectively, for relatively simple, but large XML files. > > With XML::Twig, you can give it handlers based on blocks, for instance, > you're interested in. For example: > > my $t = XML::Twig->new( > twig_handlers => { > 'person' => \§ion, > }, > ); > $t->parsefile($xmlfile); > > sub section { > my ( $t, $section ) = @_; > > # interested in a few elements within this section > do_something_with( $section->first_child_text('birthdate') ); > do_somethingelse_with( $section->first_child_text('ssn') ); > # > # ... > > # do not need that element again > $section->purge; > > return; > } > > See if that might work for you. > > John > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk From zelein at gmail.com Fri Jan 23 07:19:52 2015 From: zelein at gmail.com (Brian Mielke) Date: Fri, 23 Jan 2015 09:19:52 -0600 Subject: [Chicago-talk] Navigating an XSD In-Reply-To: References: <65bbf043f2574b1996cc58b114ae28d0@XCASPRD01-DFT.dpu.depaul.edu> <20150123142324.GA10434@aharp.iorc.depaul.edu> Message-ID: <54C26698.4040105@gmail.com> For writing XML::Writer is sufficient, though I think some DOM libraries allow you to print DOM objects to files too. As far as reader libraries, the big ones that I've used before were XML::Simple, XML::Twig, and XML::LibXML. Avoid XML::Simple. XML::Twig is ok and XML::LibXML may take more time to get started with but when I last tested those two XML::LibXML is much faster. I've not used the Mojo::DOM, but with the name Dom, it probably has similar issues with any DOM parser -- good at small data sets and very easy to code with, but slow and memory intensive with large datasets. If you are doing anything with a lot of data, you'll want to read an article on DOM vs SAX parsing, and you may want to look at XML::LibXML::Reader ( I think ). I think it's a module that allows you to event parse down to specific nodes and then build up DOM objects, which are easier to work with in code. It's been several years since I've had to do anything like that though. The most important thing with XML parsing is knowing when to use an event based parser vs a DOM parser. There may be some schema support in XML::LibXML too, but it's been a while since I've had to do anything with big xml fortunately. - Brian On 01/23/2015 08:45 AM, Jay Strauss wrote: > Hi john thanks, right now I'm going to try mojo::Dom and see how that goes > > Sent from my iPhone > >> On Jan 23, 2015, at 8:23 AM, John Kristoff wrote: >> >>> On Fri, Jan 23, 2015 at 05:12:06AM +0000, Jay Strauss wrote: >>> I have an XSD document like below. I've been googling and cpan-ing, >>> but can't find what I need (i know there are lots of XML packages), >>> and I don't know how to parse it using regexs (reliably). I just want >>> to read in this XSD and navigate it like a perl structure, and extract >>> field values like: >> [...] >>> Can anyone recommend a module or a method? >> Hi Jay. I have found some success using XML::Twig and XML::Writer for reading >> and writing respectively, for relatively simple, but large XML files. >> >> With XML::Twig, you can give it handlers based on blocks, for instance, >> you're interested in. For example: >> >> my $t = XML::Twig->new( >> twig_handlers => { >> 'person' => \§ion, >> }, >> ); >> $t->parsefile($xmlfile); >> >> sub section { >> my ( $t, $section ) = @_; >> >> # interested in a few elements within this section >> do_something_with( $section->first_child_text('birthdate') ); >> do_somethingelse_with( $section->first_child_text('ssn') ); >> #s >> # ... >> >> # do not need that element again >> $section->purge; >> >> return; >> } >> >> See if that might work for you. >> >> John >> _______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> http://mail.pm.org/mailman/listinfo/chicago-talk > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk From me at heyjay.com Fri Jan 23 08:56:37 2015 From: me at heyjay.com (Jay Strauss) Date: Fri, 23 Jan 2015 10:56:37 -0600 Subject: [Chicago-talk] Navigating an XSD In-Reply-To: References: Message-ID: Hi, now I'm a bit lost (having a hard time understanding the docs). how do I navigate to the element I want? (usable code below) (I'm happy to do it with XML::Twig too if its easy) I want to iterate through the "attributeGroup"s, getting their names, then pull out each value for "attribute name" and for "fixed". Thanks Jay #!/usr/bin/env perl use strict; use warnings; use 5.10.0; use Mojo::DOM; use Data::Dumper; my $xsd; { local $/ = undef; $xsd=; } my $dom = Mojo::DOM->new($xsd); my @things = $dom->find('attributeGroup'); __DATA__ Discharge Care Provider 1514 XCN HL70010 Discharge Care Provider Transfer Medical Service Code 1515 CE HL70069 Transfer Medical Service Code On Fri, Jan 23, 2015 at 6:56 AM, Joel Berger wrote: > I am personal partial to Mojo::DOM though it does not have any actual XSD > handling, it does xml just fine. That said, I would read through Matt > Trout's recommendations here: > http://shadow.cat/blog/matt-s-trout/mstpan-3/ > > Joel > On Jan 22, 2015 11:13 PM, "Jay Strauss" wrote: > >> Hi, >> >> I have an XSD document like below. I've been googling and cpan-ing, but >> can't find what I need (i know there are lots of XML packages), and I don't >> know how to parse it using regexs (reliably). I just want to read in this >> XSD and navigate it like a perl structure, and extract field values like: >> >> Field:ABS.1 >> Item:1514 >> Type:XCN >> Table:HL70010 >> LongName:Discharge Care Provider >> >> Field:ABS.2 >> ... >> >> >> Can anyone recommend a module or a method? >> >> Thanks >> Jay >> >> >> >> >> > xmlns:xsd="http://www.w3.org/2001/XMLSchema" >> xmlns="urn:hl7-org:v2xml" >> xmlns:hl7="urn:com.sun:encoder-hl7-1.0" >> targetNamespace="urn:hl7-org:v2xml" xmlns:jaxb=" >> http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"> >> >> >> >> >> >> >> > namespace="urn:com.sun:encoder-hl7-1.0" style="hl7encoder-1.0"/> >> >> >> >> >> >> >> >> >> >> >> >> >> Discharge Care >> Provider >> >> 1514 >> XCN >> HL70010 >> Discharge Care Provider >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> Transfer Medical Service >> Code >> >> 1515 >> CE >> HL70069 >> Transfer Medical Service Code >> >> >> >> >> >> >> >> >> >> >> _______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> http://mail.pm.org/mailman/listinfo/chicago-talk >> > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: