From: Richard W. <rw...@cs...> - 2001-06-17 11:53:57
|
Hey, Ok, here's an attempt. (lots of code follows :) Have a method: (1) protected TopicMap getTopicMap(String[] files) { XTMBuilder builder = new XTMBuilder(new TopicMapFactoryImpl()); XTMParser tmParser = new XTMParser(builder); SAXParser parser = new SAXParser(); parser.setContentHandler(tmParser); try { for (int nFile = 0; nFile < files.length; nFile++) { FileInputStream in = new FileInputStream(files[nFile]); InputSource src = new InputSource(in); parser.parse(src); } return builder.getTopicMap(); } catch (Exception ex) { ex.printStackTrace(); } return null; } ----------------------------------------------- Called with: (2) String[] files = { getObjectFileString("B.xml"), getObjectFileString("A.xml") }; TopicMap tm = tmm.getTopicMap(files); ----------------------------------------------- XTM Files: A.xml: (3) <?xml version="1.0" encoding="utf-8" standalone="yes" ?> <topicMap xmlns="http://www.topicmaps.org/xtm/1.0/" xmlns:xlink="http://www.w3.org/1999/xlink" xml:base="http://ideabank.csir.co.za/A.xml"> <topic id="m"> <baseName> <baseNameString>M</baseNameString> </baseName> </topic> <topic id="n"> <baseName> <baseNameString>N</baseNameString> </baseName> </topic> <association id="m-n"> <member> <topicRef xlink:href="#m"/> </member> <member> <topicRef xlink:href="#n"/> </member> </association> </topicMap> ------------------------------------------------- And B.xml (4) <?xml version="1.0" encoding="utf-8" standalone="yes" ?> <topicMap xmlns="http://www.topicmaps.org/xtm/1.0/" xmlns:xlink="http://www.w3.org/1999/xlink" xml:base="http://ideabank.csir.co.za/B.xml"> <topic id="test"> <baseName> <baseNameString>Test</baseNameString> </baseName> </topic> </topicMap> ----------------------------------------------------- If I use the above and print out the topic map, I get: (5) <?xml version="1.0" encoding="UTF-8"?> <topicMap xmlns="http://www.topicmaps.org/xtm/1.0/" xmlns:xlink="http://www.w3.org/1999/xlink" xml:base="http://ideabank.csir.co.za/B.xml"> <topic id="http://ideabank.csir.co.za/x1fbp0t5fb-a"/> <topic id="http://ideabank.csir.co.za/x1fbp0t5fb-4"> <baseName id="http://ideabank.csir.co.za/x1fbp0t5fb-5"> <baseNameString>N</baseNameString> </baseName> </topic> <topic id="http://ideabank.csir.co.za/x1fbp0t5fb-2"> <baseName id="http://ideabank.csir.co.za/x1fbp0t5fb-3"> <baseNameString>M</baseNameString> </baseName> </topic> <topic id="http://ideabank.csir.co.za/x1fbp0t5fb-0"> <baseName id="http://ideabank.csir.co.za/x1fbp0t5fb-1"> <baseNameString>Test</baseNameString> </baseName> </topic> <topic id="http://ideabank.csir.co.za/x1fbp0t5fb-8"/> <association id="http://ideabank.csir.co.za/x1fbp0t5fb-6"> <member id="http://ideabank.csir.co.za/x1fbp0t5fb-7"> <topicRef xlink:href="http://ideabank.csir.co.za/x1fbp0t5fb-8"/> </member> <member id="http://ideabank.csir.co.za/x1fbp0t5fb-9"> <topicRef xlink:href="http://ideabank.csir.co.za/x1fbp0t5fb-a"/> </member> </association> </topicMap> (which has an 2 extra topics, it seems for the association's topicRefs) ----------------------------------------- Whereas if I either: Load A first, using: (6) String[] files = { getObjectFileString("A.xml"), getObjectFileString("B.xml") }; (instead of String[] files = { getObjectFileString("B.xml"), getObjectFileString("A.xml") }; in (2) above) ------------------------------ OR Change the association in (3) to read: (7) <association id="m-n"> <member> <topicRef xlink:href="A.xml#m"/> </member> <member> <topicRef xlink:href="A.xml#n"/> </member> </association> (putting in the "A.xml" bit) ---------------------------------- I then get as output (8) <?xml version="1.0" encoding="UTF-8"?> <topicMap xmlns="http://www.topicmaps.org/xtm/1.0/" xmlns:xlink="http://www.w3.org/1999/xlink" xml:base="http://ideabank.csir.co.za/B.xml"> <topic id="http://ideabank.csir.co.za/x1fbp1bc1g-0"> <baseName id="http://ideabank.csir.co.za/x1fbp1bc1g-1"> <baseNameString>Test</baseNameString> </baseName> </topic> <topic id="http://ideabank.csir.co.za/x1fbp1bc1g-4"> <baseName id="http://ideabank.csir.co.za/x1fbp1bc1g-5"> <baseNameString>N</baseNameString> </baseName> </topic> <topic id="http://ideabank.csir.co.za/x1fbp1bc1g-2"> <baseName id="http://ideabank.csir.co.za/x1fbp1bc1g-3"> <baseNameString>M</baseNameString> </baseName> </topic> <association id="http://ideabank.csir.co.za/x1fbp1bc1g-6"> <member id="http://ideabank.csir.co.za/x1fbp1bc1g-7"> <topicRef xlink:href="http://ideabank.csir.co.za/x1fbp1bc1g-2"/> </member> <member id="http://ideabank.csir.co.za/x1fbp1bc1g-8"> <topicRef xlink:href="http://ideabank.csir.co.za/x1fbp1bc1g-4"/> </member> </association> </topicMap> ------------------------------------------- All of which tells me that the initial case (which produces (5)) creates two dummy topics for the association (and does not link to the existing "m" and "n") IF you load B first. If you either load A first, OR you specify the "A.xml#m" bit in the association, then it works fine. I've cut out any fiddling code in my app, so I'm pretty sure I'm not doing anything weird. I'm also using TM4J code I got on Friday off SF. Hope this helps! (and is reproducible) Rich > -----Original Message----- > From: tm4...@li... > [mailto:tm4...@li...]On Behalf Of Kal Ahmed > Sent: 15 June 2001 10:33 > To: tm4...@li... > Subject: RE: [TM4J-users] sequence of loading two files > > > Hi Rich, > > I've had a look into this and not quite figured out whats going wrong. If > both topic maps have an xml:base attribute specified, the XTMBuilder seems > to do the right thing and put the fragment identifiers on the xml:base > attribute value. If the topic maps do not have an xml:base attribute, then > the fragment identifiers get added to a default base URL > (http://topicmap.techquila.com/default). > > Perhaps I am missing something obvious here - do you have a sample of the > topic maps which cause this problem that I can have a look at ? > > Cheers, > > Kal > > > -----Original Message----- > > From: tm4...@li... > > [mailto:tm4...@li...]On Behalf Of Richard > > Watson > > Sent: 14 June 2001 21:58 > > To: TM4J Users > > Subject: [TM4J-users] sequence of loading two files > > > > > > Hi all, > > > > I'm getting a bit better at this stuff and things are working nicely. :) > > > > I've found something that looks a bit suspicious: > > > > File "A.xml" and file "B.xml" > > File A.xml has an association between #n and #m, both in A.xml. > > Both files have correct bases set. > > I load both into the same TopicMap using the XTMBuilder. > > > > Now...two cases: > > If I load A.xml into the builder and then B.xml, the > association will load > > fine. > > > > If I load B first, then the topicRefs in the association must > be "A.xml#n" > > and "A.xml#m", or they end up with resourcerefs "B.xml#n" and "B.xml#m". > > > > This a bug? > > > > Non-codey question of the day: where are you guys geographically? > > > > Cheers, > > Rich > > > > > > _______________________________________________ > > Tm4j-users mailing list > > Tm4...@li... > > http://lists.sourceforge.net/lists/listinfo/tm4j-users > > > > > > > _______________________________________________ > Tm4j-users mailing list > Tm4...@li... > http://lists.sourceforge.net/lists/listinfo/tm4j-users > |