[daisy] Daisy Detachment - update

tim_cranfield at goldenboat.net tim_cranfield at goldenboat.net
Sun Aug 13 20:40:05 CDT 2006


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);			
		}

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.

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.



More information about the daisy mailing list