Hello, but I don't seem to be able to find what I need.... Part of my application must read data created by devices from a third party. This data is provided as an XML file, but each device, of course, uses a different schema. I am adding support for a new device, and I am having trouble figuring out how to extract one specific piece of information... A simplified XML fragment looks like this: <?xml version="1.0" encoding="UTF-16" standalone="no"?> <DeviceData> <Exam Eye="R"> <ExamDate>2010-08-27T14:41:15</ExamDate> <Reading> <Sph>-15.00</Sph> <Cyl>1.50</Cyl> <Axis>97</Axis> </Reading> </Exam> <Exam Eye="L"> <ExamDate>2010-08-27T14:41:15</ExamDate> <Reading> <Sph>-15.00</Sph> <Cyl>1.50</Cyl> <Axis>97</Axis> </Reading> </Exam> </DeviceData> In my code, I create a DomParser, then get the root tag. To get the exam information, I then send #getElementsByTagName: 'Exam' nameSpaceURI: '*' to the root tag, then get the Reading information from the exam element, using the same method. This all works fine. Where I need help, is finding the attribute of the Exam elements. I can extract the readings, but I need to know if they apply to the right or left eye (attribute = "R" or "L"). When I get the exam element from the DeviceData element, I get an instance of AbtDOMElement. I see that there are methods to #getAttribute:, but I get nil back. And when I inspect the AbtDOMElement, the attributes instance variable contains an instance of AbtDOMNamedNodeMap, in which #items is a blank LookupTable. Have a made a fundamental mistake here on how I am getting the elements? Or is there something I am missing about getting the attributes for an element? Any help would be greatly appreciated..... Thanks in advance! Julian Ford You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Julian,
-- it's been at least 10 years since I tried the XML Mapping of VAST ... and finally ended up implementing my own subset of what I needed. If I remember correctly, there is no way to access attributes other than using a dtd. That's exactly why I gave up with the VAST XML mapper... If I also remember correctly, VAST views an attribute as its own kind of node and only whatever it makes from a DTD is used to (not easy to find out, as the code is very generic) determine whether a node is an embedded tag or an attribute... Maybe I am completely wrong and can learn something new from other answers... Joachim Am Montag, 14. Mai 2018 17:00:58 UTC+2 schrieb [hidden email]:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by rjuli...@gmail.com
Hi Julian,
-- Can you tell me exactly how you are creating the dom parser in code? Is the snippet you provided just an example, or would it actually demonstrate the issue? If you get it to something I can copy/paste (if possible), then I should be able to find it quickly -- Seth On Monday, May 14, 2018 at 11:00:58 AM UTC-4, [hidden email] wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
I sent only a tiny snippet, for the sake of illustration. Below, I have included a contrived example which will illustrate the issue. The code will, of course, fail on the use of the reading information, but when it breaks, you can inspect the examElement. So, I just need to be able to tell WHICH exam element I am processing, when I set the reading data. Unfortunately, the order in which the Exam elements show up are not guaranteed, so I cannot rely on that. THANKS!!! Julian ========================== | xmlParser dom aString rootTag | aString := '<?xml version="1.0" encoding="UTF-8"?> <OCT> <Exam Eye="R"> <ExamDate>2010-08-27T14:41:15</ExamDate> <Reading> <Sph>-15.00</Sph> <Cyl>1.50</Cyl> <Axis>97</Axis> </Reading> </Exam> <Exam Eye="L"> <ExamDate>2010-08-27T14:41:15</ExamDate> <Reading> <Sph>-15.00</Sph> <Cyl>1.50</Cyl> <Axis>97</Axis> </Reading> </Exam></OCT> '. xmlParser := AbtXmlDOMParser new decodingEnabled: false; yourself. [ dom := xmlParser parse: aString ] when: SgmlExceptions::SgmlException do: [ :aSignal | aSignal resumeWith: #resume ]. ( (rootTag := dom rootTag) notNil ) ifFalse: [ ^nil ]. (rootTag getElementsByTagName: 'Exam' nameSpaceURI: '*') do: [ :examElement | (examElement getElementsByTagName: 'Reading' nameSpaceURI: '*') ifNotNil: [ :reading | self setRightAutorefractorFromDomElement: reading ]. ]. You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Hey Julian,
-- When you create your xml parser...try it with the following. xmlParser := AbtXmlDOMParser newNonValidatingParser decodingEnabled: false; yourself. ...and let me know if that solves it. -- Seth On Monday, May 14, 2018 at 1:59:41 PM UTC-4, [hidden email] wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
It would appear that this does the trick!
-- Thank you!! Julian On Monday, May 14, 2018 at 3:00:09 PM UTC-4, Seth Berman wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
My pleasure...glad it worked! -- Seth On Monday, May 14, 2018 at 3:17:53 PM UTC-4, [hidden email] wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Hey...on a completely separate topic...
-- Are you still planning on going to ESUG in September? You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Indeed I am!
-- On Monday, May 14, 2018 at 4:06:47 PM UTC-4, [hidden email] wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
When are you flying in/out?
-- I have started looking at options to fly in on Sunday, and fly out on the Saturday. I gather the conference runs Monday-Friday. Planning on any extra time? On Monday, May 14, 2018 at 4:10:04 PM UTC-4, Seth Berman wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Sent you private email...
-- On Monday, May 14, 2018 at 4:17:27 PM UTC-4, [hidden email] wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by Seth Berman
Hi Seth,
-- amm I right if I assume this is exactly related to this DTD thingie? I mean, if you use a validating parser, you must provide some basis to validate upon? Joachim Am Montag, 14. Mai 2018 21:00:09 UTC+2 schrieb Seth Berman:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Hi Joachim,
-- It relates. The correct way to initialize the DOM parser is with the creational methods describing if it's validating or not....not just #new. Also, in the example, there were errors being thrown during the parse, but they were being swallowed up by the "when: SgmlExceptions::SgmlException do: [ :aSignal | aSignal resumeWith: #resume ]." so it only appeared that all was well by the time we are at the bottom of the script -- Seth On Tuesday, May 15, 2018 at 4:13:21 AM UTC-4, Joachim Tuchel wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Free forum by Nabble | Edit this page |