From: Lieberherr, Karl Sent: 22 June 2000 11:16 To: Mannion, Michael-Franz; Lieberherr, Karl Cc: Aeppli, Andre z.h.a.p.n.; Goode, Jon; 'Karl Lieberherr (E-mail)'; Hegglin, Martin; Westacott, Martin Subject: RE: XML Navigation in MAP Hi Mike: Thank you for your response. I am very pleased by it. I would love to see one of your XSLT stylesheets. Please can you point me to one. I remember you saying that it is not easy to write them and I don't have much experience with them. You hit the nail on its head when you say: >As a rule, we try to formulate stylesheets as generically in the >most modular way possible, to encourage both re-use and ease maintenance. XPath >expressions are therefore formulated in a way, which is no more and no less >specific than necessary to unambiguously identify (match) document elements. I would like to add that it is also useful to guess a bit the schema evolution that is likely to take place. This makes it sometimes beneficial to make the XPath expressions a little more specific than the current schema requires. >Regarding DOM navigation, I would be very interested in taking a look at the >library you mention. Can I use XPath expressions to navigate a DOM within Java? >That would be very useful indeed! Our current tool uses a notation that is a much simpler than the full XPath notation. And we use a notation that is different than the XPath notation. You are right that we should offer a version of our tool that uses a subset of the standard XPath notation. Also, our current tool is geared towards general purpose Java programming and is not specialized for DOM. We should offer a specialization for DOM as you suggest. Anyway, what you can do with the current tool is as follows: http://www.ccs.neu.edu/research/demeter/DJ/ You can write generic behavior such as the following count function: public int count (){ // traversal/visitor weaving getT().traverse(this, new Visitor(){ int r; public void before(Target host){ r++; } public void start() { r = 0;} …) } } The count function uses a function getT() that says where we want to navigate, in the form of a TraversalGraph object. The constructor of the TraversalGraph class takes a class graph and traversal specification (called a Strategy) as argument. The traversal specification “from BusRoute via BusStop to Person” corresponds to an XPath expression like: BusRoute//BusStop//Person. TraversalGraph getT() {return new TraversalGraph(classGraph1, new Strategy(“from BusRoute via BusStop to Person”));} The classGraph1 object is created using reflection from the .class files of your Java application. ClassGraph classGraph1 = new ClassGraph(); As you see from the above example, we use a clever, very easy to use form of the visitor design pattern to allow you to navigate through the objects in a structure-shy manner. It is also worthwhile to mention that the XPath-like expressions may be computed at runtime. This means that the XPath-like expressions will be interpreted at run-time but this is not a problem in the distributed world of MAP. I would like to discuss with you how a an XPath and DOM specialized version of the DJ tool should look like. What kind of interface would you like to have? The DJ tool uses underneath the AP library http://www.ccs.neu.edu/research/demeter/AP-Library/ and the tool you propose would be another application of this AP library. -- Karl -----Original Message----- From: Mannion, Michael-Franz Sent: 21 June 2000 13:36 To: Lieberherr, Karl Cc: Aeppli, Andre z.h.a.p.n.; Goode, Jon; 'Karl Lieberherr (E-mail)'; Hegglin, Martin; Westacott, Martin Subject: RE: XML Navigation in MAP Hello Karl Yes, we are, of course, making extensive use of XPath expressions in our XSLT stylesheets. As a rule, we try to formulate stylesheets as generically in the most modular way possible, to encourage both re-use and ease maintenance. XPath expressions are therefore formulated in a way, which is no more and no less specific than necessary to unambiguously identify (match) document elements. At the same time, I think we (those that have so far used XSLT/XPath) would be ready to admit that we certainly have not yet exploited all the possibilities offered by this powerful language. This will come with time after we have worked with a few concrete applications as opposed to experiments and prototypes. Regarding DOM navigation, I would be very interested in taking a look at the library you mention. Can I use XPath expressions to navigate a DOM within Java? That would be very useful indeed! We have investigated the JDOM API (www.jdom.org) as a means to ease the task of XML programming in Java. The API provides more intuitive interfaces than the standards from W3C. However, it does not provide any special mechanisms for structure-shy document navigation in the way you describe. Besten Dank - Mike -----Original Message----- From: Lieberherr, Karl Sent: Wednesday, June 21, 2000 12:59 PM To: Mannion, Michael-Franz Cc: Aeppli, Andre z.h.a.p.n.; Goode, Jon; 'Karl Lieberherr (E-mail)'; Hegglin, Martin Subject: XML Navigation in MAP Hi Michael: Jon Goode mentioned your name during our meeting today. We were wondering how the MAP project addresses the issue of structure-shy navigation through XML documents. Are you using the structure-shy features of XPATH? In XPath (which is used e.g. in XSLT, etc.), you can write statements like: merge(Library//Author//Book, Library//Biography//Book) + additional code not shown to answer the query: Find all books that are either about or written by some person. The DTD is, for example: but the XPATH expression would work with numerous other DTD. Are you using the capabilities of XPATH to write navigation code in a structure-shy way? Now lets assume you use DOM or another document object model to respresent the XML documents as Java objects. How do you make the navigation through those Java objects structure-shy in a similar way as XPATH makes navigation through documents structure-shy? We have a library that could be used for this purpose. The reason why I am asking: If you don't watch this issue, you might end up duplicating the object structures repeatedly in your system leading to a difficult maintenance task. -- Karl