Re: [U2] XML format question
XML, as suggested, is a flexible container but I think that the pundits suggest that you use elements for data and attributes for metadata which is used to refine or modify the default behaviour of an element. For example: 12.99 Then if you needed to store or convert the currency in your application - you have the option to do so. In your example the "Result" is described by the "precision" attribute as an "address" and the address data is contained in nested elements within the Result element. Pretty logical (though the "precision" nomenclature seems weird). So, depending on how and where you want to use the result would determine how you convert it to a dynamic array. I'd probably just convert the XML into: a [U2]attribute for the "precision" and one each for the address elements. However, you could easily put the precision into one [U2]attribute and the address elements into another [U2]attribute as multi-values. It really depends on how and where you want to use the result. Stuart Boydell -Original Message- since space concerns do not fall into place for my part, the xml has already been done, I had no control over that. I'm just trying to interpret the data correctly. > > 39.931085 > > -77.3879431001 N Some Rd > > > > > > SomewherePA15063- > 1404US > ntry> > > ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] XML format question
George: If I understand your question, all you are trying to do is figure out how to get the value of the element attributes in an XML file you are receiving. If this is what you need to accomplish, the following is an example of a portion of an extract file that shows the format to do this. For a normal element like 285.72 it would be For an element with attributes like it would be Note the use of the @ symbol and the lack of /text() on the end of the line. Hope that helps -- Carl Dula Voice: 973-227-8440 X111 Pulsar Systems, Inc.Fax: 973-227-8440 271 Route 46 West, Suite H209 email:c...@pulsarsystems.com Fairfield, NJ 07004-2474http://www.pulsarsystems.com ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] XML format question
I like to think of elements are as file folders. You can create a specific file folder for every tiny piece of data and make locating those pieces easy in a DOM based on node name. SAX, on the other hand, fires off events for every node and attribute it encounters at all levels. So, your format choice is a combination of considerations. The parser is one major thing if you're dealing with raw parsing, but if you are going to need validation then which design will be easier to write/manage an xsd for? If you aren't doing validation and the parsing method is irrelevant then the main thing to consider is readability. As Norman said earlier, an attribute-centric file will be smaller. Keep in mind, though, that attributes define properties of an element/node. They are not root nodes and therefore can not have child nodes. Therefore, no relative multi-value/nested data can be stored. The element, which said attribute is in, can have child nodes but those nodes inherit all of the parent's attributes at once. IMO, common data should be included as attributes to a root element or as elements within a container that is defined as a single, large entity by the container. Hopefully that makes sense? Glen Batchelor IT Director All-Spec Industries phone: (910) 332-0424 fax: (910) 763-5664 E-mail: webmas...@all-spec.com Web: http://www.all-spec.com Blog: http://blog.all-spec.com > -Original Message- > From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users- > boun...@listserver.u2ug.org] On Behalf Of Brian Leach > Sent: Thursday, May 13, 2010 11:24 AM > To: 'U2 Users List' > Subject: Re: [U2] XML format question > > George > > So to paraphrase, when do you use attributes to hold data and when do you > elements.. > > The problem is, there is no clear answer to this, and everyone who designs > XML schema has to grapple with this question. The only simple answer is > that > if a value could legitimately have an attribute associated with it to > qualify it, it should be an element. So in your example, the precision > attribute is qualifying the type/content of the Latitude element. But that > is really just a design and not a technical choice. > > The real answer is more pragmatic - it generally depends on what the > consumer of that data wants. In parsing terms, attributes and elements are > not the same so if the contract calls for an element, use an element; and > if > it calls for an attribute, use an attribute. > > It's a question I've asked lots of times and never really had a solid or > consistent answer. > > Brian > > -Original Message- > From: u2-users-boun...@listserver.u2ug.org > [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of George Gallen > Sent: 13 May 2010 4:06 PM > To: U2 Users List > Subject: [U2] XML format question > > I'm importing some XML, and a question came up with the following: I'm > writing a small xml extraction program >to setup a dynamic array, what is the difference between putting a > field > inside the label vs putting the field >between the tags of the label? Aren't they both a subset of the label? > I > always thought that if the field was >a single value field, it would be quoted and inside the label, but if > it > could be a multivaled field, it would go >between the field tags, with it's own field/tags. > > 39.931085 > -77.3879431001 N Some Rd > > SomewherePA15063- > 1404US ntry> > > > Could this have formatted just as well as: > > address39.931085 > -77.3879431001 N Some Rd > SomewherePA19063- > 1404US ntry> > > > or > >Address="1001 N Some Rd" City="Somewhere" State="PA" Zip="19063-1404" > Country="US"> > > > George Gallen > Senior Programmer/Analyst > Accounting/Data Division, EDI Administrator > ggal...@wyanokegroup.com > ph:856.848.9005 Ext 220 > The Wyanoke Group > http://www.wyanokegroup.com > > > > ___ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 9.0.819 / Virus Database: 271.1.1/2870 - Release Date: 05/12/10 > 19:26:00 > > ___ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] XML format question
Looking at the schema didn't shed any extra light either! > -Original Message- > From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users- > boun...@listserver.u2ug.org] On Behalf Of George Gallen > Sent: Thursday, May 13, 2010 11:29 AM > To: U2 Users List > Subject: Re: [U2] XML format question > > since space concerns do not fall into place for my part, the xml has > already been done, I > had no control over that. I'm just trying to interpret the data > correctly. > > > -Original Message- > > From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users- > > boun...@listserver.u2ug.org] On Behalf Of Norman Bauer > > Sent: Thursday, May 13, 2010 11:27 AM > > To: U2 Users List > > Subject: Re: [U2] XML format question > > > > "If space is of concern then attributes take less room, but then > again > > if > > space is of concern don't do xml, do json/csv/edi etc" > > > > excellent advice. > > > > norm > > ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] XML format question
It makes no difference for your extraction, there are no hard/fast rules as to why they have done it that way, if it is an attribute it will only be single valued, whereas if it is an element, it may be multivalued. A dtd or xsd will define if it is a multiple occurring element. -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of George Gallen Sent: 13 May 2010 16:22 To: U2 Users List Subject: Re: [U2] XML format question I'm not producing the file, I'm reading the file and was trying to figure out why some of the field were inside the label, and others were between the tags. I was trying to setup the structure of the dynamic array I am putting the data into. > -Original Message- > From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users- > boun...@listserver.u2ug.org] On Behalf Of Norman Bauer > Sent: Thursday, May 13, 2010 11:15 AM > To: U2 Users List > Subject: Re: [U2] XML format question > > George, either way will work. The by product of making xml attribute > centric > (fields inside the label) is that it produces smaller files (about half > the > size of element centric). If your producing small files that may be > read by > an admin, then go with element centric as it is easier to read. > Otherwise > attribute centric is much better for storage and transfer. > > Norm > > On Thu, May 13, 2010 at 11:06 AM, George Gallen > wrote: > > > I'm importing some XML, and a question came up with the following: > I'm > > writing a small xml extraction program > > to setup a dynamic array, what is the difference between putting a > field > > inside the label vs putting the field > > between the tags of the label? Aren't they both a subset of the > label? I > > always thought that if the field was > > a single value field, it would be quoted and inside the label, but > if it > > could be a multivaled field, it would go > > between the field tags, with it's own field/tags. > > > > 39.931085 > > -77.3879431001 N Some Rd > > > > SomewherePA15063- > 1404US > > > > > > Could this have formatted just as well as: > > > > address39.931085 > > -77.3879431001 N Some Rd > > > > SomewherePA19063- > 1404US > > > > > > or > > > > > Address="1001 N Some Rd" City="Somewhere" State="PA" Zip="19063- > 1404" > > Country="US"> > > > > > > George Gallen > > Senior Programmer/Analyst > > Accounting/Data Division, EDI Administrator > > ggal...@wyanokegroup.com > > ph:856.848.9005 Ext 220 > > The Wyanoke Group > > http://www.wyanokegroup.com > > > > > > > > ___ > > U2-Users mailing list > > U2-Users@listserver.u2ug.org > > http://listserver.u2ug.org/mailman/listinfo/u2-users > > > ___ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] XML format question
since space concerns do not fall into place for my part, the xml has already been done, I had no control over that. I'm just trying to interpret the data correctly. > -Original Message- > From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users- > boun...@listserver.u2ug.org] On Behalf Of Norman Bauer > Sent: Thursday, May 13, 2010 11:27 AM > To: U2 Users List > Subject: Re: [U2] XML format question > > "If space is of concern then attributes take less room, but then again > if > space is of concern don't do xml, do json/csv/edi etc" > > excellent advice. > > norm > > On Thu, May 13, 2010 at 11:25 AM, Symeon Breen > wrote: > > > Ahh the old attribute/element discussion - much to be said on this in > > various quarters, you may want to google on "xml elements or > attributes" to > > gain some insight. > > > > If space is of concern then attributes take less room, but then again > if > > space is of concern don't do xml, do json/csv/edi etc > > > > Personally i do as much as poss in elements, and keep the attribute > for > > simple standard things like id, date etc. It then means you can place > > things > > like cdata into all your fields and so limits you less in some regard > > > > Rgds > > Symeon. > > > > > > > > -Original Message- > > From: u2-users-boun...@listserver.u2ug.org > > [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of George > Gallen > > Sent: 13 May 2010 16:06 > > To: U2 Users List > > Subject: [U2] XML format question > > > > I'm importing some XML, and a question came up with the following: > I'm > > writing a small xml extraction program > > to setup a dynamic array, what is the difference between putting a > field > > inside the label vs putting the field > > between the tags of the label? Aren't they both a subset of the > label? I > > always thought that if the field was > > a single value field, it would be quoted and inside the label, but > if it > > could be a multivaled field, it would go > > between the field tags, with it's own field/tags. > > > > 39.931085 > > -77.3879431001 N Some Rd > > > > > > SomewherePA15063- > 1404US > ntry> > > > > > > Could this have formatted just as well as: > > > > address39.931085 > > -77.3879431001 N Some Rd > > > > SomewherePA19063- > 1404US > ntry> > > > > > > or > > > > > Address="1001 N Some Rd" City="Somewhere" State="PA" Zip="19063- > 1404" > > Country="US"> > > > > > > George Gallen > > Senior Programmer/Analyst > > Accounting/Data Division, EDI Administrator > > ggal...@wyanokegroup.com > > ph:856.848.9005 Ext 220 > > The Wyanoke Group > > http://www.wyanokegroup.com > > > > > > > > ___ > > U2-Users mailing list > > U2-Users@listserver.u2ug.org > > http://listserver.u2ug.org/mailman/listinfo/u2-users > > > > ___ > > U2-Users mailing list > > U2-Users@listserver.u2ug.org > > http://listserver.u2ug.org/mailman/listinfo/u2-users > > > ___ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] XML format question
"If space is of concern then attributes take less room, but then again if space is of concern don't do xml, do json/csv/edi etc" excellent advice. norm On Thu, May 13, 2010 at 11:25 AM, Symeon Breen wrote: > Ahh the old attribute/element discussion - much to be said on this in > various quarters, you may want to google on "xml elements or attributes" to > gain some insight. > > If space is of concern then attributes take less room, but then again if > space is of concern don't do xml, do json/csv/edi etc > > Personally i do as much as poss in elements, and keep the attribute for > simple standard things like id, date etc. It then means you can place > things > like cdata into all your fields and so limits you less in some regard > > Rgds > Symeon. > > > > -Original Message- > From: u2-users-boun...@listserver.u2ug.org > [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of George Gallen > Sent: 13 May 2010 16:06 > To: U2 Users List > Subject: [U2] XML format question > > I'm importing some XML, and a question came up with the following: I'm > writing a small xml extraction program > to setup a dynamic array, what is the difference between putting a field > inside the label vs putting the field > between the tags of the label? Aren't they both a subset of the label? I > always thought that if the field was > a single value field, it would be quoted and inside the label, but if it > could be a multivaled field, it would go > between the field tags, with it's own field/tags. > > 39.931085 > -77.3879431001 N Some Rd > > > SomewherePA15063-1404US ntry> > > > Could this have formatted just as well as: > > address39.931085 > -77.3879431001 N Some Rd > > SomewherePA19063-1404US ntry> > > > or > > Address="1001 N Some Rd" City="Somewhere" State="PA" Zip="19063-1404" > Country="US"> > > > George Gallen > Senior Programmer/Analyst > Accounting/Data Division, EDI Administrator > ggal...@wyanokegroup.com > ph:856.848.9005 Ext 220 > The Wyanoke Group > http://www.wyanokegroup.com > > > > ___ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users > > ___ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users > ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] XML format question
Ahh the old attribute/element discussion - much to be said on this in various quarters, you may want to google on "xml elements or attributes" to gain some insight. If space is of concern then attributes take less room, but then again if space is of concern don't do xml, do json/csv/edi etc Personally i do as much as poss in elements, and keep the attribute for simple standard things like id, date etc. It then means you can place things like cdata into all your fields and so limits you less in some regard Rgds Symeon. -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of George Gallen Sent: 13 May 2010 16:06 To: U2 Users List Subject: [U2] XML format question I'm importing some XML, and a question came up with the following: I'm writing a small xml extraction program to setup a dynamic array, what is the difference between putting a field inside the label vs putting the field between the tags of the label? Aren't they both a subset of the label? I always thought that if the field was a single value field, it would be quoted and inside the label, but if it could be a multivaled field, it would go between the field tags, with it's own field/tags. 39.931085 -77.3879431001 N Some Rd SomewherePA15063-1404US Could this have formatted just as well as: address39.931085 -77.3879431001 N Some Rd SomewherePA19063-1404US or George Gallen Senior Programmer/Analyst Accounting/Data Division, EDI Administrator ggal...@wyanokegroup.com ph:856.848.9005 Ext 220 The Wyanoke Group http://www.wyanokegroup.com ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] XML format question
George So to paraphrase, when do you use attributes to hold data and when do you elements.. The problem is, there is no clear answer to this, and everyone who designs XML schema has to grapple with this question. The only simple answer is that if a value could legitimately have an attribute associated with it to qualify it, it should be an element. So in your example, the precision attribute is qualifying the type/content of the Latitude element. But that is really just a design and not a technical choice. The real answer is more pragmatic - it generally depends on what the consumer of that data wants. In parsing terms, attributes and elements are not the same so if the contract calls for an element, use an element; and if it calls for an attribute, use an attribute. It's a question I've asked lots of times and never really had a solid or consistent answer. Brian -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of George Gallen Sent: 13 May 2010 4:06 PM To: U2 Users List Subject: [U2] XML format question I'm importing some XML, and a question came up with the following: I'm writing a small xml extraction program to setup a dynamic array, what is the difference between putting a field inside the label vs putting the field between the tags of the label? Aren't they both a subset of the label? I always thought that if the field was a single value field, it would be quoted and inside the label, but if it could be a multivaled field, it would go between the field tags, with it's own field/tags. 39.931085 -77.3879431001 N Some Rd SomewherePA15063-1404US Could this have formatted just as well as: address39.931085 -77.3879431001 N Some Rd SomewherePA19063-1404US or George Gallen Senior Programmer/Analyst Accounting/Data Division, EDI Administrator ggal...@wyanokegroup.com ph:856.848.9005 Ext 220 The Wyanoke Group http://www.wyanokegroup.com ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.819 / Virus Database: 271.1.1/2870 - Release Date: 05/12/10 19:26:00 ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] XML format question
I'm not producing the file, I'm reading the file and was trying to figure out why some of the field were inside the label, and others were between the tags. I was trying to setup the structure of the dynamic array I am putting the data into. > -Original Message- > From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users- > boun...@listserver.u2ug.org] On Behalf Of Norman Bauer > Sent: Thursday, May 13, 2010 11:15 AM > To: U2 Users List > Subject: Re: [U2] XML format question > > George, either way will work. The by product of making xml attribute > centric > (fields inside the label) is that it produces smaller files (about half > the > size of element centric). If your producing small files that may be > read by > an admin, then go with element centric as it is easier to read. > Otherwise > attribute centric is much better for storage and transfer. > > Norm > > On Thu, May 13, 2010 at 11:06 AM, George Gallen > wrote: > > > I'm importing some XML, and a question came up with the following: > I'm > > writing a small xml extraction program > > to setup a dynamic array, what is the difference between putting a > field > > inside the label vs putting the field > > between the tags of the label? Aren't they both a subset of the > label? I > > always thought that if the field was > > a single value field, it would be quoted and inside the label, but > if it > > could be a multivaled field, it would go > > between the field tags, with it's own field/tags. > > > > 39.931085 > > -77.3879431001 N Some Rd > > > > SomewherePA15063- > 1404US > > > > > > Could this have formatted just as well as: > > > > address39.931085 > > -77.3879431001 N Some Rd > > > > SomewherePA19063- > 1404US > > > > > > or > > > > > Address="1001 N Some Rd" City="Somewhere" State="PA" Zip="19063- > 1404" > > Country="US"> > > > > > > George Gallen > > Senior Programmer/Analyst > > Accounting/Data Division, EDI Administrator > > ggal...@wyanokegroup.com > > ph:856.848.9005 Ext 220 > > The Wyanoke Group > > http://www.wyanokegroup.com > > > > > > > > ___ > > U2-Users mailing list > > U2-Users@listserver.u2ug.org > > http://listserver.u2ug.org/mailman/listinfo/u2-users > > > ___ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] XML format question
George, either way will work. The by product of making xml attribute centric (fields inside the label) is that it produces smaller files (about half the size of element centric). If your producing small files that may be read by an admin, then go with element centric as it is easier to read. Otherwise attribute centric is much better for storage and transfer. Norm On Thu, May 13, 2010 at 11:06 AM, George Gallen wrote: > I'm importing some XML, and a question came up with the following: I'm > writing a small xml extraction program > to setup a dynamic array, what is the difference between putting a field > inside the label vs putting the field > between the tags of the label? Aren't they both a subset of the label? I > always thought that if the field was > a single value field, it would be quoted and inside the label, but if it > could be a multivaled field, it would go > between the field tags, with it's own field/tags. > > 39.931085 > -77.3879431001 N Some Rd > > > SomewherePA15063-1404US > > > Could this have formatted just as well as: > > address39.931085 > -77.3879431001 N Some Rd > > SomewherePA19063-1404US > > > or > > Address="1001 N Some Rd" City="Somewhere" State="PA" Zip="19063-1404" > Country="US"> > > > George Gallen > Senior Programmer/Analyst > Accounting/Data Division, EDI Administrator > ggal...@wyanokegroup.com > ph:856.848.9005 Ext 220 > The Wyanoke Group > http://www.wyanokegroup.com > > > > ___ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users > ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
[U2] XML format question
I'm importing some XML, and a question came up with the following: I'm writing a small xml extraction program to setup a dynamic array, what is the difference between putting a field inside the label vs putting the field between the tags of the label? Aren't they both a subset of the label? I always thought that if the field was a single value field, it would be quoted and inside the label, but if it could be a multivaled field, it would go between the field tags, with it's own field/tags. 39.931085 -77.3879431001 N Some Rd SomewherePA15063-1404US Could this have formatted just as well as: address39.931085 -77.3879431001 N Some Rd SomewherePA19063-1404US or George Gallen Senior Programmer/Analyst Accounting/Data Division, EDI Administrator ggal...@wyanokegroup.com ph:856.848.9005 Ext 220 The Wyanoke Group http://www.wyanokegroup.com ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users