[daisy] Daisy Detachment - update
Marc Portier
mpo at outerthought.org
Mon Aug 14 02:12:16 CDT 2006
tim_cranfield at goldenboat.net wrote:
> Hi,
>
> I am currently working on the editing of html, and in particular, the
> ability to add images in an editor, from which documents can be created
> offline and then uploaded to a repository.
>
> Documents can now only be uploaded to the repository they cam from, as
> per this post:
> http://lists.cocoondev.org/pipermail/daisy/2006-August/004656.html
>
> For Documents created offline (which at present is only image
> DOcuments), this defaults to the parent Document's repository.
>
> I am trying to keep a reference in mappings.xml of which Documents a
> Document is linked to. This only applies to Documents with an html Part.
> Basically:
> <imgLinks>
> <imgLink docId="4"/>
> <imgLink docId="366"/>
> </imgLinks>
>
> When the Document is edited img elements may of course be added and
> removed. I am having trouble removing elements with xmlbeans. After
> editing I want to remove the old imgLink mappings and add new ones. I try:
> MappingsDocument.Mappings.Mapping.ImgLinks.ImgLink[] imgLinkArray;
> imgLinkArray = mapDoc.getImgLinks().getImgLinkArray();
> for (int i = 0; i < imgLinkArray.length; i++) {
> mapDoc.getImgLinks.removeImgLink(i);
> }
>
given the expected side-effect of remove() I think you end up having
indexes go beyond the actual size at the moment you make calls to
remove() that go beyond half of the original size of the array?
I see you keep incrementing your index corresponding the length of
imgLinkArray variable which is referring to the original array, not the
'current' one.
My guess would be that a new call to getImgLinks() will return a smaller
array after each called remove..
Some ideas to get out of this
1/ either count down from length to zero
2/ or keep removing the first element index == 0 in stead
3/ unsure, but I guess there is also a setImgLinks() as well? in which
case I'ld prefer
[a] if you need to remove all:
- setImgeLinks(new ImgLinks[0]);
[b] if your end-goal is to actually modify the list:
- getting the array
- converting to list
- modify the list so it fits your needs
- convert to array
- hand that to setImgLinks()
by the way: I noticed, you checked in the mappings-jar into svn, is that
the result of the xsd compilation with xbeans? if so we should just have
maven build it and place it up in the local repo, rather then publish it
through svn
> but it throws an IndexOutOfBounds exception on an xmlbeans removeElement
> method on the removeImgLink() line.
>
> Secondly, I am using the cyberneko HTML parser to convert HTML parts
> between DaisyHtml and normal HTML:
> FileInputStream inStream = new FileInputStream(partFile);
> InputSource inSource = new InputSource(inStream);
> org.apache.xerces.parsers.DOMParser parser = new
> org.apache.xerces.parsers.DOMParser(new HTMLConfiguration());
>
> parser.setProperty("http://cyberneko.org/html/properties/names/elems",
> "lower");
>
> parser.setFeature("http://cyberneko.org/html/features/balance-tags", true);
> parser.parse(inSource);
> org.w3c.dom.Document htmlDocument = parser.getDocument();
>
> It does not, however, balance tags such as img, and after uploading to
> the repository an error such as "no matching end tag for..." is shown in
> the wiki.
>
hm, I'm not sure but you might be confusing two things here
when the parser is 'balancing tags' that would mean that on the levem of
the sax-api it is ensuring balanced start- and stop- element events, so
to be making your claim you'ld need to check it on that level
however, if you make your claim based on the serialized version of
things, then you should be aware that it's probably will have been the
serializer (typically part of xalan) that will have removed the
'balance' again, just before saving to file
make sure you have the output-option of your serializer (empty
transformer) set to xml, not html if you want <img/> coming out of that
if that's to dense as an explanation, just point me to the code where
you parse/save this stuff, and I'll have a closer look
> I used an HTML parser because of course an XML parser gives the same
> error message: "no matching end tag for..". I tried using the
> HTMLCleaner to fix up the tags but this also gave the same error message
> when I tried parsing the html with it.
>
> So at present I do not know how to clean up the html.
>
> I will be heading overseas for a couple of weeks on Thursday, so it may
> give people a chance to have a look at the program and come up with
> problems/improvements so I can at least finish with something useful.
>
cool,
I'll try to catch up with things shortly
looking at the formal google-timeline:
> August 21, 2006:
> - All student projects due by 08:00 Pacific Daylight Time
> - Final mentor evaluations of student progress commence
> - Student evaluations of mentors commence
>
> September 5, 2006:
> - All mentor and student evaluations due by 08:00 Pacific Daylight Time
> - Google begins issuing final student payments
> - Google program administrators begin review of students' evaluations of their mentors
you are probably best placed to see if you need to make some
arrangements with Google to meet those deadlines (experience with
earlier ones this year show that some days of delay are not uncommon)
enjoy your trip
-marc=
--
Marc Portier http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at http://blogs.cocoondev.org/mpo/
mpo at outerthought.org mpo at apache.org
More information about the daisy
mailing list