Generating the JPEG Files

page 185 xsl:message terminate=yes Error Zip file library not available xsl:message xsl:otherwise xsl:choose xsl:template In the extension function code itself, we start by creating the ZipOutputStream itself: ZipOutputStream zipOut = new ZipOutputStreamnew FileOutputStreamcurrentDirectory + fileSeparator + baseFilename + .zip; Once weve created our ZipOutputStream , well see if theres a comment for the zip file in the zip-file-comment attribute of the tutorial element: Node currentNode = tutorialElement.nextNode; while currentNode = null { if currentNode.getLocalName.equalstutorial { ElementImpl currentElement = ElementImplcurrentNode; String zipFileComment = currentElement.getAttributezip-file-comment; if zipFileComment = null zipOut.setCommentzipFileComment; else { zipFileComment = currentElement.getAttributealt; if zipFileComment = null zipOut.setCommentzipFileComment; } With everything we do with the DOM nodes, well need to make sure we actually work with the appropriate nodes; thats why we use the function call getLocalName.equalstutorial . Once weve found the tutorial element, we can work with its children to figure out the names of all the HTML and JPEG files we need to add to the zip file. If the tutorial element has five section children, and the first section contains eleven panel s, then well need to write the files tootomatic-1-1.html through tootomatic-1-11.html to the zip file. This assumes that the base filename we use is tootomatic . Heres an excerpt from the code: int numKids = currentElement.getChildCount; int numSections = 0; for int i = 0; i numKids; i++ { Node currentChild = currentElement.getChildi; if currentChild.getLocalName.equalssection { ElementImpl currentChildElement = ElementImplcurrentChild fileToZip = new FilecurrentDirectory + fileSeparator + index + ++numSections + .html; fis = new FileInputStreamfileToZip; entry = new ZipEntrycurrentDirectory + fileSeparator + fileToZip.getName; if zipOut = null { zipOut.putNextEntryentry; whilebytes_read = fis.readbuffer = -1 zipOut.writebuffer, 0, bytes_read; } fis.close; int numGrandkids = currentChildElement.getChildCount; int numPanels = 0; for int j = 0; j numGrandkids; j++ {