diff options
Diffstat (limited to 'xmerge/java/org/openoffice/xmerge/converter/xml/xslt')
21 files changed, 5786 insertions, 0 deletions
diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/ConverterCapabilitiesImpl.java b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/ConverterCapabilitiesImpl.java new file mode 100644 index 000000000000..079437336f8e --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/ConverterCapabilitiesImpl.java @@ -0,0 +1,93 @@ +/************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.xmerge.converter.xml.xslt; + +import org.openoffice.xmerge.ConverterCapabilities; +import org.openoffice.xmerge.converter.xml.OfficeConstants; + +/** + * <p>Xslt implementation of <code>ConverterCapabilities</code> for + * the {@link + * org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl + * PluginFactoryImpl}.</p> + * + * <p>Used with StarWriter XML to/from XSLT supported formats conversions. The + * <code>ConverterCapibilies</code> specify which "Office" + * <code>Document</code> tags and attributes are supported on the + * "Device" <code>Document</code> format.</p> + */ +public final class ConverterCapabilitiesImpl + implements ConverterCapabilities { + + public boolean canConvertTag(String tag) { + + if (OfficeConstants.TAG_OFFICE_DOCUMENT.equals(tag)) + return true; + else if (OfficeConstants.TAG_OFFICE_DOCUMENT_CONTENT.equals(tag)) + return true; + else if (OfficeConstants.TAG_OFFICE_BODY.equals(tag)) + return true; + else if (OfficeConstants.TAG_PARAGRAPH.equals(tag)) + return true; + else if (OfficeConstants.TAG_HEADING.equals(tag)) + return true; + else if (OfficeConstants.TAG_ORDERED_LIST.equals(tag)) + return true; + else if (OfficeConstants.TAG_UNORDERED_LIST.equals(tag)) + return true; + else if (OfficeConstants.TAG_LIST_ITEM.equals(tag)) + return true; + else if (OfficeConstants.TAG_LIST_HEADER.equals(tag)) + return true; + else if (OfficeConstants.TAG_SPAN.equals(tag)) + return true; + else if (OfficeConstants.TAG_HYPERLINK.equals(tag)) + return true; + else if (OfficeConstants.TAG_LINE_BREAK.equals(tag)) + return true; + else if (OfficeConstants.TAG_SPACE.equals(tag)) + return true; + else if (OfficeConstants.TAG_TAB_STOP.equals(tag)) + return true; + + return false; + } + + public boolean canConvertAttribute(String tag, + String attribute) { + + if (OfficeConstants.TAG_SPACE.equals(tag)) { + + if (OfficeConstants.ATTRIBUTE_SPACE_COUNT.equals(attribute)) + return true; + } + + return false; + } +} + diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentDeserializerImpl.java b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentDeserializerImpl.java new file mode 100644 index 000000000000..08d294982537 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentDeserializerImpl.java @@ -0,0 +1,254 @@ +/************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.xmerge.converter.xml.xslt; + +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; +import org.w3c.dom.Element; + +import java.io.InputStream; +import java.io.IOException; +import java.util.Enumeration; +import java.io.ByteArrayOutputStream; +import java.io.ByteArrayInputStream; + + + + +import org.openoffice.xmerge.Document; +import org.openoffice.xmerge.ConvertData; +import org.openoffice.xmerge.ConvertException; +import org.openoffice.xmerge.DocumentDeserializer; +import org.openoffice.xmerge.converter.dom.DOMDocument; +//import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; +import org.openoffice.xmerge.converter.xml.xslt.GenericOfficeDocument; +import org.openoffice.xmerge.util.Debug; +import org.openoffice.xmerge.util.registry.ConverterInfo; + +// Imported TraX classes +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.dom.DOMSource; +//import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import javax.xml.transform.URIResolver; +import javax.xml.transform.Source; + + +// +//import org.apache.xalan.serialize.Serializer; +//import org.apache.xalan.serialize.SerializerFactory; +//import org.apache.xalan.templates.OutputProperties; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +// Imported java classes +import java.io.FileNotFoundException; + + +/** + * <p>Xslt implementation of + * org.openoffice.xmerge.DocumentSerializer + * for the {@link + * org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl + * PluginFactoryImpl}.</p> + * + * <p>The <code>serialize</code> method transforms the DOM + * document from the given <code>Document</code> object by + * means of a supplied Xsl Stylesheet.</p> + * + * @author Aidan Butler + */ +public final class DocumentDeserializerImpl + implements DocumentDeserializer,URIResolver { + + /** A <code>ConvertData</code> object assigned to this object. */ + private InputStream is = null; + private ConvertData cd = null; + private PluginFactoryImpl pluginFactory = null; + + /** + * Constructor that assigns the given <code>ConvertData</code> + * to this object. + * + * @param pf A <code>PluginFactoryImpl</code> object. + * + * @param cd A <code>ConvertData</code> object to read data for + * the conversion process by the <code>deserialize</code> + * method. + */ + public DocumentDeserializerImpl(PluginFactoryImpl pf,ConvertData cd) { + this.cd = cd; + pluginFactory = pf; + } + + + + /* + * This method performs the xslt transformation on the supplied <code> + * Document</code> and returns a <code>ByteArrayOutputStream</code> object. + * + * Xslt transformation code + * + * @returns baos A <code>ByteArrayOutputStream</code> object containing + * the result of the Xslt transformation. + * @throws TransformerException,TransformerConfigurationException + * , FileNotFoundException,IOException + * + */ + public Document deserialize() throws ConvertException, IOException { + log("\nFound the XSLT deserializer"); + Enumeration enumer = cd.getDocumentEnumeration(); + org.w3c.dom.Document domDoc=null; + DOMDocument docOut=null; + GenericOfficeDocument doc = null; + ByteArrayOutputStream baos =null; + GenericOfficeDocument sxwDoc = new GenericOfficeDocument("output"); + while (enumer.hasMoreElements()) { + docOut = (DOMDocument) enumer.nextElement(); + } + domDoc = docOut.getContentDOM(); + try{ + baos = transform(domDoc); + sxwDoc.initContentDOM(); + DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance(); + dFactory.setNamespaceAware(true); + DocumentBuilder dBuilder = dFactory.newDocumentBuilder(); + sxwDoc.setContentDOM(dBuilder.parse(new ByteArrayInputStream(baos.toByteArray()))); + + } + catch(Exception e){ + System.out.println("The following error occurred:"+e); + } + return sxwDoc; + } + + public Source resolve(String href,String base) + throws TransformerException{ + //System.out.println("\nhref "+href+"\nbase "+base); + if (href !=null){ + if(href.equals("javax.xml.transform.dom.DOMSource")|| href.equals("")) + return null; + try{ + ConverterInfo ci = pluginFactory.getConverterInfo(); + String newhRef ="jar:"+ci.getJarName()+"!/"+href; + //System.out.println("\n Looking For "+ newhRef); + StreamSource sheetFile= new StreamSource(newhRef); + return sheetFile; + } + catch (Exception e){ + System.out.println("\nException in Xslt Resolver " +e); + return null; + } + } + else + return null; + } + + /* + * This method performs the xslt transformation on the supplied Dom Tree. + * + * Xslt transformation code + * + * @throws TransformerException,TransformerConfigurationException + * , FileNotFoundException,IOException + * + */ + private ByteArrayOutputStream transform(org.w3c.dom.Document xmlDoc) + throws TransformerException,TransformerConfigurationException + , FileNotFoundException,IOException{ + + log("\nTransforming..."); + ConverterInfo ci = pluginFactory.getConverterInfo(); + ByteArrayOutputStream baos= new ByteArrayOutputStream(); + try{ + DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance(); + dFactory.setNamespaceAware(true); + DocumentBuilder dBuilder = dFactory.newDocumentBuilder(); + + String teststr = ci.getXsltDeserial(); + teststr= teststr.substring(0,6); + org.w3c.dom.Document xslDoc=null; + if ((teststr.equals("http:/"))||(teststr.equals("file:/")) + ||(teststr.equals("jar://"))){ + log(ci.getXsltDeserial()); + xslDoc= dBuilder.parse(ci.getXsltDeserial()); + + } + else{ + log(ci.getJarName()+"!/"+ci.getXsltDeserial()); + xslDoc = dBuilder.parse( + "jar:"+ci.getJarName()+"!/"+ci.getXsltDeserial()); + } + + + DOMSource xslDomSource = new DOMSource(xslDoc); + DOMSource xmlDomSource = new DOMSource(xmlDoc); + + //call the tranformer using the XSL, Source and Result dom. + TransformerFactory tFactory = TransformerFactory.newInstance(); + tFactory.setURIResolver(this); + Transformer transformer = tFactory.newTransformer(xslDomSource); + transformer.transform(xmlDomSource,new StreamResult(baos)); + /* + // Serialize for output to standard out + Serializer serializer = SerializerFactory.getSerializer + (OutputProperties.getDefaultMethodProperties("xml")); + serializer.setOutputStream(System.out); + serializer.asDOMSerializer().serialize(xmlDomResult.getNode()); + */ + + log("\n** Transform Complete ***"); + + } + catch (StackOverflowError sOE){ + System.out.println("\nERROR : Stack Overflow Error During Transformation\n Try increasing the stack size by passing the -Xss1m option to the JRE."); + throw sOE; + } + catch(Exception e){ + System.out.println("An error occured in the transformation : "+e); + } + return baos; + } + + /** + * Sends message to the log object. + * + * @param str Debug message. + */ + private void log(String str) { + + Debug.log(Debug.TRACE, str); + } + +} + diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentMergerImpl.java b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentMergerImpl.java new file mode 100644 index 000000000000..a320080a43cb --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentMergerImpl.java @@ -0,0 +1,99 @@ +/************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.xmerge.converter.xml.xslt; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import org.openoffice.xmerge.DocumentMerger; +import org.openoffice.xmerge.MergeException; +import org.openoffice.xmerge.ConverterCapabilities; +import org.openoffice.xmerge.converter.xml.xslt.GenericOfficeDocument; +import org.openoffice.xmerge.merger.DiffAlgorithm; +import org.openoffice.xmerge.merger.Difference; +import org.openoffice.xmerge.merger.NodeMergeAlgorithm; +import org.openoffice.xmerge.merger.Iterator; +import org.openoffice.xmerge.merger.DiffAlgorithm; +import org.openoffice.xmerge.merger.diff.ParaNodeIterator; +import org.openoffice.xmerge.merger.diff.IteratorLCSAlgorithm; +import org.openoffice.xmerge.merger.merge.DocumentMerge; +import org.openoffice.xmerge.merger.merge.CharacterBaseParagraphMerge; +import org.openoffice.xmerge.util.Debug; + + +/** + * Xslt implementation of <code>DocumentMerger</code> + * for the {@link + * org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl + * PluginFactoryImpl}.</p> + */ +public class DocumentMergerImpl implements DocumentMerger { + + private ConverterCapabilities cc_; + private org.openoffice.xmerge.Document orig = null; + + public DocumentMergerImpl(org.openoffice.xmerge.Document doc, ConverterCapabilities cc) { + cc_ = cc; + this.orig = doc; + } + + public void merge(org.openoffice.xmerge.Document modifiedDoc) throws MergeException { + + GenericOfficeDocument wdoc1 = (GenericOfficeDocument) orig; + GenericOfficeDocument wdoc2 = (GenericOfficeDocument) modifiedDoc; + + Document doc1 = wdoc1.getContentDOM(); + Document doc2 = wdoc2.getContentDOM(); + + Iterator i1 = new ParaNodeIterator(cc_, doc1.getDocumentElement()); + Iterator i2 = new ParaNodeIterator(cc_, doc2.getDocumentElement()); + + DiffAlgorithm diffAlgo = new IteratorLCSAlgorithm(); + + // find out the paragrah level diffs + Difference[] diffTable = diffAlgo.computeDiffs(i1, i2); + + if (Debug.isFlagSet(Debug.INFO)) { + Debug.log(Debug.INFO, "Diff Result: "); + + for (int i = 0; i < diffTable.length; i++) { + Debug.log(Debug.INFO, diffTable[i].debug()); + } + } + + // merge the paragraphs + NodeMergeAlgorithm charMerge = new CharacterBaseParagraphMerge(); + DocumentMerge docMerge = new DocumentMerge(cc_, charMerge); + + Iterator result = null; + + docMerge.applyDifference(i1, i2, diffTable); + } +} + + diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentSerializerImpl.java b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentSerializerImpl.java new file mode 100644 index 000000000000..b4b1650f97f6 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/DocumentSerializerImpl.java @@ -0,0 +1,309 @@ +/************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.xmerge.converter.xml.xslt; + +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; +import org.w3c.dom.Element; +import org.w3c.dom.*; + +import java.io.IOException; +import java.io.InputStream; +import java.io.ByteArrayOutputStream; +import java.io.ByteArrayInputStream; +import java.util.Enumeration; +import java.util.Properties; + +import org.openoffice.xmerge.Document; +import org.openoffice.xmerge.ConvertData; +import org.openoffice.xmerge.ConvertException; +import org.openoffice.xmerge.DocumentSerializer; +import org.openoffice.xmerge.converter.xml.xslt.GenericOfficeDocument; +import org.openoffice.xmerge.converter.dom.DOMDocument; +import org.openoffice.xmerge.util.Debug; +import org.openoffice.xmerge.util.registry.ConverterInfo; +import org.openoffice.xmerge.converter.xml.OfficeConstants; + +// Imported TraX classes +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.stream.StreamSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.URIResolver; +import javax.xml.transform.Source; + +// +import org.apache.xalan.serialize.Serializer; +import org.apache.xalan.serialize.SerializerFactory; +import org.apache.xalan.templates.OutputProperties; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +// Imported java classes +import java.io.FileNotFoundException; +import java.io.File; +import java.net.URI; + +/** + * <p>Xslt implementation of + * org.openoffice.xmerge.DocumentSerializer + * for the {@link + * org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl + * PluginFactoryImpl}.</p> + * + * <p>The <code>serialize</code> method transforms the DOM + * document from the given <code>Document</code> object by + * means of a supplied Xsl Stylesheet.</p> + * + * @author Aidan Butler + */ + + +public final class DocumentSerializerImpl + implements DocumentSerializer,OfficeConstants,URIResolver { + + + /** SXW <code>Document</code> object that this converter processes. */ + private GenericOfficeDocument sxwDoc = null; + + private PluginFactoryImpl pluginFactory = null; + + /** + * Constructor. + * + * @param pf A <code>PluginFactoryImpl</code> + * @param doc A SXW <code>Document</code> to be converted. + */ + public DocumentSerializerImpl(PluginFactoryImpl pf,Document doc) { + pluginFactory=pf; + sxwDoc = (GenericOfficeDocument) doc; + } + + + /** + * Method to convert a <code>Document</code> with an xsl stylesheet. + * It creates a <code>Document</code> object, which is then transformed + * with the Xslt processer. A <code>ConvertData </code> object is + * constructed and returned. + * + * @returns cd A <code>ConvertData</code> object. + * @throws ConvertException If any I/O error occurs. + * @throws IOException If any I/O error occurs. + */ + public ConvertData serialize() throws ConvertException, IOException { + String docName = sxwDoc.getName(); + org.w3c.dom.Document domDoc = sxwDoc.getContentDOM(); + org.w3c.dom.Document metaDoc = sxwDoc.getMetaDOM(); + org.w3c.dom.Document styleDoc = sxwDoc.getStyleDOM(); + ByteArrayOutputStream baos= new ByteArrayOutputStream(); + ConvertData cd = new ConvertData(); + Node offnode = (Node)domDoc.getDocumentElement(); + if (!(offnode.getNodeName()).equals("office:document")){ + try{ + DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder= builderFactory.newDocumentBuilder(); + DOMImplementation domImpl = builder.getDOMImplementation(); + DocumentType docType =domImpl.createDocumentType("office:document","-//OpenOffice.org//DTD OfficeDocument 1.0//EN",null); + org.w3c.dom.Document newDoc = domImpl.createDocument("http://openoffice.org/2000/office","office:document",docType); + + + Element rootElement=newDoc.getDocumentElement(); + rootElement.setAttribute("xmlns:office","http://openoffice.org/2000/office"); + rootElement.setAttribute("xmlns:style","http://openoffice.org/2000/style" ); + rootElement.setAttribute("xmlns:text","http://openoffice.org/2000/text"); + rootElement.setAttribute("xmlns:table","http://openoffice.org/2000/table"); + + rootElement.setAttribute("xmlns:draw","http://openoffice.org/2000/drawing"); + rootElement.setAttribute("xmlns:fo","http://www.w3.org/1999/XSL/Format" ); + rootElement.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink" ); + rootElement.setAttribute("xmlns:dc","http://purl.org/dc/elements/1.1/" ); + rootElement.setAttribute("xmlns:meta","http://openoffice.org/2000/meta" ); + rootElement.setAttribute("xmlns:number","http://openoffice.org/2000/datastyle" ); + rootElement.setAttribute("xmlns:svg","http://www.w3.org/2000/svg" ); + rootElement.setAttribute("xmlns:chart","http://openoffice.org/2000/chart" ); + rootElement.setAttribute("xmlns:dr3d","http://openoffice.org/2000/dr3d" ); + rootElement.setAttribute("xmlns:math","http://www.w3.org/1998/Math/MathML" ); + rootElement.setAttribute("xmlns:form","http://openoffice.org/2000/form" ); + rootElement.setAttribute("xmlns:script","http://openoffice.org/2000/script" ); + rootElement.setAttribute("xmlns:config","http://openoffice.org/2001/config" ); + rootElement.setAttribute("office:class","text" ); + rootElement.setAttribute("office:version","1.0"); + + + NodeList nodeList; + Node tmpNode; + Node rootNode = (Node)rootElement; + if (metaDoc !=null){ + nodeList= metaDoc.getElementsByTagName(TAG_OFFICE_META); + if (nodeList.getLength()>0){ + tmpNode = newDoc.importNode(nodeList.item(0),true); + rootNode.appendChild(tmpNode); + } + } if (styleDoc !=null){ + nodeList= styleDoc.getElementsByTagName(TAG_OFFICE_STYLES); + if (nodeList.getLength()>0){ + tmpNode = newDoc.importNode(nodeList.item(0),true); + rootNode.appendChild(tmpNode); + } + }if (domDoc !=null){ + nodeList= domDoc.getElementsByTagName(TAG_OFFICE_AUTOMATIC_STYLES); + if (nodeList.getLength()>0){ + tmpNode = newDoc.importNode(nodeList.item(0),true); + rootNode.appendChild(tmpNode); + } + nodeList= domDoc.getElementsByTagName(TAG_OFFICE_BODY); + if (nodeList.getLength()>0){ + tmpNode = newDoc.importNode(nodeList.item(0),true); + rootNode.appendChild(tmpNode); + } + } + domDoc=newDoc; + }catch(Exception e){ + System.out.println("\nAn Exception occurred with Xslt Serializer"+e); + } + + } + + try{ + baos=transform(domDoc); + } + catch (Exception e){ + System.out.println("\n Error with Xslt\n"); + } + + String ext = pluginFactory.getDeviceFileExtension(); + DOMDocument resultDomDoc=(DOMDocument)pluginFactory.createDeviceDocument(docName,new ByteArrayInputStream(baos.toByteArray())); + cd.addDocument (resultDomDoc); + return cd; + } + + public Source resolve(String href,String base) + throws TransformerException{ + //System.out.println("\nhref "+href+"\nbase "+base); + if (href !=null){ + if(href.equals("javax.xml.transform.dom.DOMSource")|| href.equals("")) + return null; + try{ + ConverterInfo ci = pluginFactory.getConverterInfo(); + String newhRef ="jar:"+ci.getJarName()+"!/"+href; + //System.out.println("\n Looking For "+ newhRef); + StreamSource sheetFile= new StreamSource(newhRef); + return sheetFile; + } + catch (Exception e){ + System.out.println("\nException in Xslt Resolver " +e); + return null; + } + } + else + return null; + } + + + /* + * This method performs the sxl transformation on the supplied <code> + * Document</code> and returns a <code>DOMResult</code> object. + * + * Xslt transformation code + * + * @returns baos A <code>ByteArrayOutputStream</code> object containing + * the result of the Xslt transformation. + * @throws TransformerException,TransformerConfigurationException + * , FileNotFoundException,IOException + * + */ + + + private ByteArrayOutputStream transform(org.w3c.dom.Document domDoc) + throws TransformerException,TransformerConfigurationException + , FileNotFoundException,IOException{ + //System.out.println("\nTransforming..."); + ConverterInfo ci = pluginFactory.getConverterInfo(); + //DOMResult xmlDomResult = new DOMResult(); + ByteArrayOutputStream baos= new ByteArrayOutputStream(); + try{ + + DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance(); + dFactory.setNamespaceAware(true); + + DocumentBuilder dBuilder = dFactory.newDocumentBuilder(); + String teststr = ci.getXsltSerial(); + + teststr= teststr.substring(0,6); + org.w3c.dom.Document xslDoc=null; + if ((teststr.equals("http:/"))||(teststr.equals("file:/")) + ||(teststr.equals("jar://"))){ + System.out.println(ci.getXsltSerial()); + xslDoc= dBuilder.parse(ci.getXsltSerial()); + + } + else{ + //System.out.println(ci.getJarName()+"!/"+ci.getXsltSerial()); + xslDoc = dBuilder.parse( + "jar:"+ci.getJarName()+"!/"+ci.getXsltSerial()); + } + + DOMSource xslDomSource = new DOMSource(xslDoc); + DOMSource xmlDomSource = new DOMSource(domDoc); + + //call the tranformer using the XSL, Source and Result. + TransformerFactory tFactory = TransformerFactory.newInstance(); + tFactory.setURIResolver(this); + Transformer transformer = tFactory.newTransformer(xslDomSource); + + transformer.transform(xmlDomSource, new StreamResult(baos)); + + /* + transformer.transform(xmlDomSource, xmlDomResult); //Removed this impl because the DocType was not being written out + + // Serialize for output to standard out + Serializer serializer = SerializerFactory.getSerializer + (OutputProperties.getDefaultMethodProperties("xml")); + //serializer.setOutputStream(System.out); + serializer.setOutputStream(baos); + serializer.asDOMSerializer().serialize(xmlDomResult.getNode()); + //serializer.asDOMSerializer().serialize(xmlDomSource.getNode()); + + + //System.out.println("\n** Transform Complete ***"); + */ + } + catch(Exception e){ + System.out.println("An error occured in the transformation : "+e); + } + return baos; + } + + +} + diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/GenericOfficeDocument.java b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/GenericOfficeDocument.java new file mode 100644 index 000000000000..d2b98819c87a --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/GenericOfficeDocument.java @@ -0,0 +1,95 @@ +/************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.xmerge.converter.xml.xslt; + +import org.w3c.dom.Document; +import org.openoffice.xmerge.converter.xml.OfficeDocument; +import org.openoffice.xmerge.converter.xml.OfficeConstants; + +/** + * This class is an implementation of <code>OfficeDocument</code> for + * the generic office format. + */ +public class GenericOfficeDocument extends OfficeDocument { + + /** + * Constructor with arguments to set <code>name</code>. + * + * @param name The name of the <code>Document</code> + */ + public GenericOfficeDocument(String name) { + super(name); + } + + + /** + * Constructor with arguments to set <code>name</code>, the + * <code>namespaceAware</code> flag, and the <code>validating</code> + * flag. + * + * @param name The name of the <code>Document</code>. + * @param namespaceAware The value of the <code>namespaceAware</code> + * flag. + * @param validating The value of the <code>validating</code> flag. + */ + public GenericOfficeDocument(String name, boolean namespaceAware, boolean validating) { + + super(name, namespaceAware, validating); + } + + /** + * Returns the Office file extension for the generic format. + * + * @return The Office file extension for the generic format. + */ + protected String getFileExtension() { + return ""; + } + + /** + * Returns the Office attribute for the generic format. + * + * @return The Office attribute for the generic format. + */ + protected String getOfficeClassAttribute() { + + return ""; + } + + /** + * Method to return the MIME type of the document. + * + * @return String The document's MIME type. + */ + protected String getDocumentMimeType() { + /* TODO: Determine the MIME-type from the input. */ + return ""; + } + +} + diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/PluginFactoryImpl.java b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/PluginFactoryImpl.java new file mode 100644 index 000000000000..cb3a9c507b82 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/PluginFactoryImpl.java @@ -0,0 +1,204 @@ +/************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.xmerge.converter.xml.xslt; + +import org.openoffice.xmerge.Document; +import org.openoffice.xmerge.ConvertData; +import org.openoffice.xmerge.DocumentSerializer; +import org.openoffice.xmerge.DocumentSerializerFactory; +import org.openoffice.xmerge.DocumentDeserializer; +import org.openoffice.xmerge.DocumentDeserializerFactory; +import org.openoffice.xmerge.PluginFactory; +import org.openoffice.xmerge.converter.dom.DOMDocument; +//import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; +//import org.openoffice.xmerge.converter.xml.OfficeDocument; +import org.openoffice.xmerge.converter.xml.xslt.GenericOfficeDocument; +import org.openoffice.xmerge.util.registry.ConverterInfo; +import org.openoffice.xmerge.DocumentMerger; +import org.openoffice.xmerge.DocumentMergerFactory; +import org.openoffice.xmerge.ConverterCapabilities; +import org.openoffice.xmerge.util.registry.ConverterInfo; + +import java.io.InputStream; +import java.util.Enumeration; +import java.io.InputStream; +import java.io.IOException; +import java.util.Properties; + +/** + * <p>Xslt implementation of the <code>PluginFactory</code>. + * This encapsulates conversion of StarWriter XML format to and from + * a supported format.</p> + * + * <p>The superclass produces a particular + * {@link org.openoffice.xmerge.Document Document} + * object, i.e. {@link + * org.openoffice.xmerge.converter.xml.sxw.SxwDocument + * SxwDocument} that the converters in this class work with. Thus, + * this class only implements the methods that produces the converters, + * i.e. {@link + * org.openoffice.xmerge.DocumentSerializer + * DocumentSerializer} and {@link + * org.openoffice.xmerge.DocumentDeserializer + * DocumentDeserializer}</p> + * + * @author Aidan Butler + */ +public final class PluginFactoryImpl extends PluginFactory + implements DocumentDeserializerFactory, DocumentSerializerFactory, DocumentMergerFactory +{ + + public PluginFactoryImpl (ConverterInfo ci) { + super(ci); + } + + /** ConverterCapabilities object for this type of conversion. */ + private final static ConverterCapabilities converterCap = + new ConverterCapabilitiesImpl(); + + + /** + * Returns an instance of <code>DocumentSerializerImpl</code>, + * which is an implementation of the <code>DocumentSerializer</code> + * interface. + * + * @param doc <code>Document</code> object to be + * converted/serialized. + * + * @return A <code>DocumentSerializerImpl</code> object. + */ + public DocumentSerializer createDocumentSerializer(Document doc) { + return new DocumentSerializerImpl(this,doc); + } + + + /** + * Returns an instance of <code>DocumentDeserializerImpl</code>, + * which is an implementation of the <code>DocumentDeserializer</code> + * interface. + * + * @param is <code>ConvertData</code> object. + * + * @return A DocumentDeserializerImpl object. + */ + public DocumentDeserializer createDocumentDeserializer(ConvertData cd) { + + return new DocumentDeserializerImpl(this,cd); + } + + public org.openoffice.xmerge.Document createDeviceDocument(java.lang.String str, java.io.InputStream inputStream) throws java.io.IOException { + String ext = this.getDeviceFileExtension(); + DOMDocument domDoc = new DOMDocument(str,ext); + domDoc.read(inputStream); + return domDoc; + } + + + public Document createOfficeDocument(String name, InputStream is) + throws IOException { + + // read zipped XML stream + GenericOfficeDocument doc = new GenericOfficeDocument(name); + doc.read(is); + return doc; + } + + public Document createOfficeDocument(String name, InputStream is,boolean isZip) + throws IOException { + + // read zipped XML stream + GenericOfficeDocument doc = new GenericOfficeDocument(name); + doc.read(is,isZip); + return doc; + } + + /** + * Returns a <code>String</code> containing the file extension of a + * <code>Document</code>. This method uses a properties file to determine + * a mapping from the device mime in the <code>ConverterInfo</code> to a + * particular file extension. If a mapping is not specified, the default + * is ".txt". + * + * @return <code>String</code>. + */ + + + public String getDeviceFileExtension(){ + Class c = this.getClass(); + InputStream is = c.getResourceAsStream("XsltPlugin.properties"); + Properties props = new Properties(); + String ext= ".txt"; + String mimeType = null; + ConverterInfo ci = this.getConverterInfo(); + Enumeration enumer = ci.getDeviceMime(); + while (enumer.hasMoreElements()) { + mimeType= (String) enumer.nextElement(); + } + try { + props.load(is); + + String info = props.getProperty(mimeType); + if (info != null) { + ext = info; + } + } catch (Exception e) { + + // It is okay for the property file to not exist. + // + } + return ext; + } + + /** + * Returns an instance of <code>DocumentMergerImpl</code>, + * which is an implementation of the <code>DocumentMerger</code> + * interface. + * + * @param doc <code>Document</code> to merge. + * + * @return A DocumentMergerImpl object. + */ + public DocumentMerger createDocumentMerger(Document doc) { + ConverterCapabilities cc = converterCap; + DocumentMergerImpl merger = new DocumentMergerImpl(doc, cc); + return merger; + + } + +} + + + + + + + + + + + diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/XsltPlugin.properties b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/XsltPlugin.properties new file mode 100644 index 000000000000..32f3771fc492 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/XsltPlugin.properties @@ -0,0 +1,36 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + + +# +# XsltPlugin.properties +# + +#This file allows users to specify the mime-type to file extension mappings + +# e.g text/html=.html +text/html=.html diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/build.xml b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/build.xml new file mode 100644 index 000000000000..43db663b2820 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/build.xml @@ -0,0 +1,136 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + + Copyright 2000, 2010 Oracle and/or its affiliates. + + OpenOffice.org - a multi-platform office productivity suite + + This file is part of OpenOffice.org. + + OpenOffice.org is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + OpenOffice.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details + (a copy is included in the LICENSE file that accompanied this code). + + You should have received a copy of the GNU Lesser General Public License + version 3 along with OpenOffice.org. If not, see + <http://www.openoffice.org/license.html> + for a copy of the LGPLv3 License. + +--> +<project name="xmrg_jooxcx_xslt" default="main" basedir="."> + + <!-- ================================================================= --> + <!-- settings --> + <!-- ================================================================= --> + + <!-- project prefix, used for targets and build.lst --> + <property name="prj.prefix" value="xmrg"/> + + <!-- name of this sub target used in recursive builds --> + <property name="target" value="xmrg_jooxcx_xslt"/> + + <!-- relative path to project directory --> + <property name="prj" value="../../../../../../../"/> + + <!-- start of java source code package structure --> + <property name="java.dir" value="${prj}/java"/> + + <!-- path component for current java package --> + <property name="package" + value="org/openoffice/xmerge/converter/xml/xslt/"/> + + <!-- define how to handle CLASSPATH environment --> + <property name="build.sysclasspath" value="ignore"/> + + <!-- classpath settings for javac tasks --> + <path id="classpath"> + <pathelement location="${build.class}"/> + <pathelement location="${solar.jar}/xalan.jar"/> + <pathelement location="${solar.jar}/parser.jar"/> + <pathelement location="${solar.jar}/jaxp.jar"/> + <pathelement location="${solar.jar}/xerces.jar"/> + </path> + + <!-- set wether we want to compile with or without deprecation --> + <property name="deprecation" value="on"/> + + <!-- ================================================================= --> + <!-- solar build environment targets --> + <!-- ================================================================= --> + + <target name="build_dir" unless="build.dir"> + <property name="build.dir" value="${out}"/> + </target> + + <target name="solar" depends="build_dir" if="solar.update"> + <property name="solar.properties" + value="${solar.bin}/solar.properties"/> + </target> + + <target name="init" depends="solar"> + <property name="build.compiler" value="classic"/> + <property file="${solar.properties}"/> + <property file="${build.dir}/class/solar.properties"/> + </target> + + <target name="info"> + <echo message="--------------------"/> + <echo message="${target}"/> + <echo message="--------------------"/> + </target> + + + <!-- ================================================================= --> + <!-- custom targets --> + <!-- ================================================================= --> + + <!-- the main target, called in recursive builds --> + <target name="main" depends="info,prepare,compile"/> + + <!-- prepare output directories --> + <target name="prepare" depends="init" if="build.class"> + <mkdir dir="${build.dir}"/> + <mkdir dir="${build.class}"/> + </target> + + <!-- compile java sources in ${package} --> + <target name="compile" depends="prepare" if="build.class"> + <javac srcdir="${java.dir}" + destdir="${build.class}" + debug="${debug}" + deprecation="${deprecation}" + optimize="${optimize}"> + <classpath refid="classpath"/> + <include name="${package}/DocumentDeserializerImpl.java"/> + <include name="${package}/DocumentSerializerImpl.java"/> + <include name="${package}/GenericOfficeDocument.java"/> + <include name="${package}/PluginFactoryImpl.java"/> + </javac> + <copy todir="${build.class}/${package}"> + <fileset dir="."> + <include name="*.properties"/> + </fileset> + </copy> + </target> + + <!-- clean up --> + <target name="clean" depends="prepare"> + <delete includeEmptyDirs="true"> + <fileset dir="${build.class}"> + <patternset> + <include name="${package}/*.class"/> + </patternset> + </fileset> + </delete> + </target> + +</project> + diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/converter.xml b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/converter.xml new file mode 100644 index 000000000000..3baf857406ca --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/converter.xml @@ -0,0 +1,50 @@ +<?xml version="1.0"?> +<!-- + + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + + Copyright 2000, 2010 Oracle and/or its affiliates. + + OpenOffice.org - a multi-platform office productivity suite + + This file is part of OpenOffice.org. + + OpenOffice.org is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + OpenOffice.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details + (a copy is included in the LICENSE file that accompanied this code). + + You should have received a copy of the GNU Lesser General Public License + version 3 along with OpenOffice.org. If not, see + <http://www.openoffice.org/license.html> + for a copy of the LGPLv3 License. + +--> +<!--<!DOCTYPE converters SYSTEM "converter.dtd">--> +<converters> + <converter type="staroffice/sxw" version="1.0"> + <converter-display-name> + XSLT Transformation + </converter-display-name> + <converter-description> + Converter which performs xslt transformations + </converter-description> + <converter-vendor>OpenOffice.org</converter-vendor> + <converter-class-impl> + org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl + </converter-class-impl> + <converter-xslt-serialize> + sofftohtml.xsl + </converter-xslt-serialize> + <converter-xslt-deserialize> + htmltosoff.xsl + </converter-xslt-deserialize> + <converter-target type="text/html" /> + </converter> +</converters> + diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/docbookfilter/DBFilter.java b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/docbookfilter/DBFilter.java new file mode 100644 index 000000000000..eae4a03c5bc6 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/docbookfilter/DBFilter.java @@ -0,0 +1,570 @@ +/************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +//Standard Java classes +import java.util.Enumeration; +import java.util.Vector; +import java.io.InputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.ByteArrayOutputStream; +import java.io.ByteArrayInputStream; +import com.sun.star.xml.XImportFilter; +import com.sun.star.xml.XExportFilter; +import java.io.*; +import java.util.regex.*; + +// Imported TraX classes +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import javax.xml.transform.URIResolver; +import javax.xml.transform.Source; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.OutputKeys; + +//StarOffice Interfaces and UNO +import com.sun.star.uno.AnyConverter; +import com.sun.star.lang.XInitialization; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.lang.XTypeProvider; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.comp.loader.FactoryHelper; +import com.sun.star.lang.XServiceName; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.registry.XRegistryKey; +import com.sun.star.frame.XConfigManager; +import com.sun.star.xml.sax.InputSource; +import com.sun.star.xml.sax.XParser; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.xml.sax.XDocumentHandler; + +//Uno to java Adaptor +import com.sun.star.lib.uno.adapter.*; + +/** This outer class provides an inner class to implement the service + * description, a method to instantiate the + * component on demand (__getServiceFactory()), and a method to give + * information about the component (__writeRegistryServiceInfo()). + */ +public class DBFilter { + + + private static XMultiServiceFactory xMSF; + + /** This inner class provides the component as a concrete implementation + * of the service description. It implements the needed interfaces. + * @implements XTypeProvider + */ + public static class _DBFilter implements + XImportFilter, + XExportFilter, + XServiceName, + XServiceInfo, + XDocumentHandler, + XTypeProvider { + + private boolean indent; + private XInputStream xInStream; + private XOutputStream xOutStream; + private XOutputStream xos; + private String sExportStyleSheet; + private String doctype_public; + private String doctype_system; + + public _DBFilter() + { + indent = false; + xInStream = null; + xOutStream = null; + xos = null; + sExportStyleSheet = null; + doctype_public = null; + doctype_system = null; + } + + /** The component will be registered under this name. + */ + static private final String __serviceName = "com.sun.star.documentconversion.DBFilter"; + + public com.sun.star.uno.Type[] getTypes() { + Type[] typeReturn = {}; + + try { + typeReturn = new Type[] { + new Type( XTypeProvider.class ), + new Type( XExportFilter.class ), + new Type( XImportFilter.class ), + new Type( XServiceName.class ), + new Type( XServiceInfo.class ) }; + } + catch( Exception exception ) { + + } + + return( typeReturn ); + } + + + public boolean importer(com.sun.star.beans.PropertyValue[] aSourceData, + com.sun.star.xml.sax.XDocumentHandler xDocHandler, + java.lang.String[] msUserData) throws com.sun.star.uno.RuntimeException,com.sun.star.lang.IllegalArgumentException { + /* + System.out.println("\nFound the Java Importer!\n"); + + System.out.println("\n"+msUserData[0]); + System.out.println("\n"+msUserData[1]); + System.out.println("\n"+msUserData[2]); + System.out.println("\n"+msUserData[3]); + System.out.println("\n"+xDocHandler); + System.out.println("\n"+msUserData[4]); + System.out.println("\n"+msUserData[5]); + */ + String sFileName=null; + String udImport =msUserData[2]; + String sImportStyleSheet =msUserData[4]; + sExportStyleSheet =msUserData[5]; + com.sun.star.io.XInputStream xis=null; + com.sun.star.beans.PropertyValue[] pValue = aSourceData; + + for (int i = 0 ; i < pValue.length; i++) + { + try{ + //System.out.println("\n"+pValue[i].Name+" "+pValue[i].Value); + if (pValue[i].Name.compareTo("InputStream")==0){ + xis=(com.sun.star.io.XInputStream)AnyConverter.toObject(new Type(com.sun.star.io.XInputStream.class), pValue[i].Value); + } + else if (pValue[i].Name.compareTo("FileName")==0){ + sFileName=(String)AnyConverter.toObject(new Type(java.lang.String.class), pValue[i].Value); + } + else if (pValue[i].Name.compareTo("Indent")==0){ //to be changed to new value for indentation from XSLT UI + indent=(boolean)AnyConverter.toBoolean(pValue[i].Value); + } + else if (pValue[i].Name.compareTo("DocType_Public")==0){ + doctype_public = AnyConverter.toString(pValue[i].Value); + } + else if (pValue[i].Name.compareTo("DocType_System")==0){ + doctype_system = AnyConverter.toString(pValue[i].Value); + } } + catch(com.sun.star.lang.IllegalArgumentException AnyExec){ + System.out.println("\nIllegalArgumentException "+AnyExec); + } + + } + + try{ + + Object xCfgMgrObj=xMSF.createInstance("com.sun.star.config.SpecialConfigManager"); + XConfigManager xCfgMgr = (XConfigManager) UnoRuntime.queryInterface( + XConfigManager.class , xCfgMgrObj ); + String PathString=xCfgMgr.substituteVariables("$(progurl)" ); + PathString= PathString.concat("/"); + Object xPipeObj=xMSF.createInstance("com.sun.star.io.Pipe"); + xInStream = (XInputStream) UnoRuntime.queryInterface( + XInputStream.class , xPipeObj ); + xOutStream = (XOutputStream) UnoRuntime.queryInterface( + XOutputStream.class , xPipeObj ); + if (!sImportStyleSheet.equals("")){ + if (!sImportStyleSheet.startsWith("file:")&&!sImportStyleSheet.startsWith("http:") + &&!sExportStyleSheet.startsWith("shttp:") + &&!sExportStyleSheet.startsWith("jar:")){ + sImportStyleSheet=PathString.concat(sImportStyleSheet); + } + } + convert (xis,xOutStream,sImportStyleSheet,true); + xOutStream.closeOutput(); + Object xSaxParserObj=xMSF.createInstance("com.sun.star.xml.sax.Parser"); + XParser xParser = (XParser) UnoRuntime.queryInterface( + XParser.class , xSaxParserObj ); + InputSource aInput = new InputSource(); + if (sFileName==null) + sFileName=" "; + aInput.sSystemId = sFileName; + aInput.aInputStream =xInStream; + xParser.setDocumentHandler ( xDocHandler ); + xParser.parseStream ( aInput ); + xInStream.closeInput(); + + } + catch (Exception AnyExec){ + //e.printStackTrace(); + System.out.println("\nException "+AnyExec); + throw new com.sun.star.uno.RuntimeException(AnyExec.getMessage()); + } + return true; + } + + + + public boolean exporter(com.sun.star.beans.PropertyValue[] aSourceData, + java.lang.String[] msUserData) throws com.sun.star.uno.RuntimeException,com.sun.star.lang.IllegalArgumentException { + /* + System.out.println("\nFound the Exporter!\n"); + + System.out.println("\n0"+msUserData[0]); + System.out.println("\n1"+msUserData[1]); + System.out.println("\n2"+msUserData[2]); + System.out.println("\n3"+msUserData[3]); + + System.out.println("\n4"+msUserData[4]); + System.out.println("\n5"+msUserData[5]); + */ + String udImport =msUserData[2]; + sExportStyleSheet =msUserData[5]; + com.sun.star.beans.PropertyValue[] pValue = aSourceData; + for (int i = 0 ; i < pValue.length; i++) + { + try{ + //System.out.println("\n"+pValue[i].Name+" "+pValue[i].Value); + if (pValue[i].Name.compareTo("OutputStream")==0){ + xos=(com.sun.star.io.XOutputStream)AnyConverter.toObject(new Type(com.sun.star.io.XOutputStream.class), pValue[i].Value); + // System.out.println(pValue[i].Name+" "+xos); + } + else if (pValue[i].Name.compareTo("Indent")==0){ //to be changed to new value for indentation from XSLT UI + indent=(boolean)AnyConverter.toBoolean(pValue[i].Value); + } + else if (pValue[i].Name.compareTo("DocType_Public")==0){ + doctype_public = AnyConverter.toString(pValue[i].Value); + } + else if (pValue[i].Name.compareTo("DocType_System")==0){ + doctype_system = AnyConverter.toString(pValue[i].Value); + } + + } + catch(com.sun.star.lang.IllegalArgumentException AnyExec){ + System.out.println("\nIllegalArgumentException "+AnyExec); + } + } + + + try{ + + Object xCfgMgrObj=xMSF.createInstance("com.sun.star.config.SpecialConfigManager"); + XConfigManager xCfgMgr = (XConfigManager) UnoRuntime.queryInterface( + XConfigManager.class , xCfgMgrObj ); + + String PathString=xCfgMgr.substituteVariables("$(progurl)" ); + PathString= PathString.concat("/"); + Object xPipeObj=xMSF.createInstance("com.sun.star.io.Pipe"); + xInStream = (XInputStream) UnoRuntime.queryInterface( + XInputStream.class , xPipeObj ); + xOutStream = (XOutputStream) UnoRuntime.queryInterface( + XOutputStream.class , xPipeObj ); + if (!sExportStyleSheet.equals("")){ + if (!sExportStyleSheet.startsWith("file:")&&!sExportStyleSheet.startsWith("http:") + &&!sExportStyleSheet.startsWith("shttp:") + &&!sExportStyleSheet.startsWith("jar:")){ + sExportStyleSheet=PathString.concat(sExportStyleSheet); + } + } + } + catch (Exception AnyExec){ + System.out.println("Exception "+AnyExec); + throw new com.sun.star.uno.RuntimeException(AnyExec.getMessage()); + } + return true; + } + + public String replace(String origString, String origChar, String replaceChar){ + String tmp=""; + int index=origString.indexOf(origChar); + if(index !=-1){ + while (index !=-1){ + String first =origString.substring(0,index); + first=first.concat(replaceChar); + tmp=tmp.concat(first); + origString=origString.substring(index+1,origString.length()); + index=origString.indexOf(origChar); + if(index==-1) { + tmp=tmp.concat(origString); + } + } + } + return tmp; + } + + public String needsMask(String origString){ + + if (origString.indexOf("&")!=-1){ + origString=replace(origString,"&","&"); + } + if (origString.indexOf("\"")!=-1){ + origString=replace(origString,"\"","""); + } + if (origString.indexOf("<")!=-1){ + origString=replace(origString,"<","<"); + } + if (origString.indexOf(">")!=-1){ + origString=replace(origString,">",">"); + } + return origString; + } + + + + public void startDocument (){ + } + + public void endDocument() + { + convert (xInStream,xos,sExportStyleSheet,false); + } + + public void startElement (String str, com.sun.star.xml.sax.XAttributeList xattribs) + { + + str="<".concat(str); + if (xattribs !=null) + { + str= str.concat(" "); + int len=xattribs.getLength(); + for (short i=0;i<len;i++) + { + str=str.concat(xattribs.getNameByIndex(i)); + str=str.concat("=\""); + //str=str.concat(xattribs.getValueByIndex(i)); + str=str.concat(needsMask(xattribs.getValueByIndex(i))); + str=str.concat("\" "); + } + } + str=str.concat(">"); + //System.out.println(str); + try{ + //xOutStream.writeBytes(str.getBytes()); + xOutStream.writeBytes(str.getBytes("UTF-8")); + } + catch (Exception e){ + System.out.println("\n"+e); + } + + } + + public void endElement(String str){ + str="</".concat(str); + str=str.concat(">"); + str=str.concat("\n"); + try{ + xOutStream.writeBytes(str.getBytes("UTF-8")); + } + catch (Exception e){ + System.out.println("\n"+e); + } + // System.out.println(str); + + } + public void characters(String str){ + str=needsMask(str); + try{ + xOutStream.writeBytes(str.getBytes("UTF-8")); + } + catch (Exception e){ + System.out.println("\n"+e); + } + + } + + public void ignorableWhitespace(String str){ + + + } + public void processingInstruction(String aTarget, String aData){ + + } + + public void setDocumentLocator(com.sun.star.xml.sax.XLocator xLocator){ + + } + + private String maskEntities(String xmlString){ + Pattern testpattern = Pattern.compile("<!ENTITY [a-zA-Z0-9#]* "); + Matcher testmatch= testpattern.matcher(xmlString); + //System.out.println("\nStarting replace"); + int offset=0; + while (testmatch.find(offset)){ + String newstring = xmlString.substring(testmatch.start()+9,testmatch.end()-1); + offset= testmatch.end(); + //System.out.println("\nReplacing " +newstring); + + xmlString=xmlString.replaceAll("&"+newstring+";","<entity name=\""+newstring+"\">"+"&"+newstring+";"+"</entity>"); + testmatch = testmatch.reset(); + testmatch= testpattern.matcher(xmlString); + //System.out.println("\nFound Pattern "+testmatch.replaceFirst("<entity>"+newstring+"</entity>")); + newstring= ""; + } + return xmlString; + } + + public void convert (com.sun.star.io.XInputStream xml, + com.sun.star.io.XOutputStream device,String sStyleSheet,boolean importing ) throws com.sun.star.uno.RuntimeException { + XInputStreamToInputStreamAdapter xis =new XInputStreamToInputStreamAdapter(xml); + XOutputStreamToOutputStreamAdapter xos = + new XOutputStreamToOutputStreamAdapter(device); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + String xmlFile=null; + try{ + //call the tranformer using the XSL, Source and Result dom. + TransformerFactory tFactory = TransformerFactory.newInstance(); + //tFactory.setURIResolver(this); + Transformer transformer =null; + transformer = tFactory.newTransformer( new StreamSource(sStyleSheet)); + if(indent){ // required for displaying XML correctly in XSLT UI + transformer.setOutputProperty("indent", "yes"); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "1"); + } + if(null != doctype_public){ + transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctype_public); + } + if(null != doctype_system){ + transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctype_system); + } + if (importing) + { + byte tmpArr[]=new byte[1000]; + while (xis.available()>0){ + int read = xis.read(tmpArr); + baos.write(tmpArr,0,read); + tmpArr =new byte[1000]; + } + xmlFile = maskEntities(baos.toString("UTF-8")); + + //xmlFile = baos.toString("UTF-8"); + if (xmlFile.indexOf("<!DOCTYPE")!=-1){ + String tag= xmlFile.substring(xmlFile.lastIndexOf("/")+1,xmlFile.lastIndexOf(">")); + String entities = ""; + if(xmlFile.indexOf("[",xmlFile.indexOf("<!DOCTYPE"))!=-1){ + if(xmlFile.indexOf("[",xmlFile.indexOf("<!DOCTYPE")) < xmlFile.indexOf(">",xmlFile.indexOf("<!DOCTYPE"))){ + entities = xmlFile.substring(xmlFile.indexOf("[",xmlFile.indexOf("<!DOCTYPE")),xmlFile.indexOf("]",xmlFile.indexOf("<!DOCTYPE"))+1); + } + } + String newDocType = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE "+tag+" "+entities+">"; + xmlFile= xmlFile.substring(xmlFile.indexOf("<"+tag,0), xmlFile.lastIndexOf(">")+1); + xmlFile= newDocType.concat(xmlFile); + //throw new com.sun.star.uno.RuntimeException(xmlFile); + } + ByteArrayInputStream bais = new ByteArrayInputStream(xmlFile.getBytes("UTF-8")); + transformer.transform(new StreamSource(bais),new StreamResult(xos)); + } + else + transformer.transform(new StreamSource(xis),new StreamResult(xos)); + } + catch (TransformerConfigurationException transConfExc) + { + throw new com.sun.star.uno.RuntimeException(transConfExc.getMessage()); + } + catch (TransformerException transExc){ + //System.out.println("\nException "+ e); + throw new com.sun.star.uno.RuntimeException(transExc.getMessage()); + } + catch (Exception e){ + System.out.println("\nException "+ e); + throw new com.sun.star.uno.RuntimeException(e.getMessage()); + } + } + + + + + // Implement methods from interface XTypeProvider + public byte[] getImplementationId() { + byte[] byteReturn = {}; + + byteReturn = new String( "" + this.hashCode() ).getBytes(); + + return( byteReturn ); + } + + // Implement method from interface XServiceName + public String getServiceName() { + return( __serviceName ); + } + + // Implement methods from interface XServiceInfo + public boolean supportsService(String stringServiceName) { + return( stringServiceName.equals( __serviceName ) ); + } + + public String getImplementationName() { + return( _DBFilter.class.getName() ); + } + + public String[] getSupportedServiceNames() { + String[] stringSupportedServiceNames = { __serviceName }; + return( stringSupportedServiceNames ); + } + } + + /** + * Returns a factory for creating the service. + * This method is called by the <code>JavaLoader</code> + * + * @return returns a <code>XSingleServiceFactory</code> for creating the + * component + * + * @param implName the name of the implementation for which a + * service is desired + * @param multiFactory the service manager to be used if needed + * @param regKey the registryKey + * + * @see com.sun.star.comp.loader.JavaLoader + */ + public static XSingleServiceFactory __getServiceFactory(String implName, + XMultiServiceFactory multiFactory, + XRegistryKey regKey) { + XSingleServiceFactory xSingleServiceFactory = null; + xMSF= multiFactory; + if (implName.equals(_DBFilter.class.getName()) ) { + xSingleServiceFactory = FactoryHelper.getServiceFactory(_DBFilter.class, + _DBFilter.__serviceName, + multiFactory, + regKey); + } + + return xSingleServiceFactory; + } + + /** + * Writes the service information into the given registry key. + * This method is called by the <code>JavaLoader</code> + * <p> + * @return returns true if the operation succeeded + * @param regKey the registryKey + * @see com.sun.star.comp.loader.JavaLoader + */ + public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { + + return FactoryHelper.writeRegistryServiceInfo(_DBFilter.class.getName(), + _DBFilter.__serviceName, regKey); + } +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/docbookfilter/Manifest b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/docbookfilter/Manifest new file mode 100644 index 000000000000..108fba617702 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/docbookfilter/Manifest @@ -0,0 +1 @@ +RegistrationClassName: DBFilter diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/docbookfilter/Readme.txt b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/docbookfilter/Readme.txt new file mode 100644 index 000000000000..d67b2aaeeac9 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/docbookfilter/Readme.txt @@ -0,0 +1,14 @@ +DBFilter Readme +=============== + +The DocBook filter (DBFilter) is essentially teh XSLTFilter that is +delivered with Openoffice, except that it contains an extra routine +for Masking DOCTYPE Entity declarations. In this way, Entities +which are referenced inside the XML Document to be imported, +are converted into an <entity name="ent_name"> tag. In this way, +the entities can be imported into OOo as "set" and "get" variables. + +On Export, these variables can be written out once again as correct +Enity decls and Entity references. + +
\ No newline at end of file diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/docbookfilter/makefile.mk b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/docbookfilter/makefile.mk new file mode 100644 index 000000000000..9f5a92570565 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/docbookfilter/makefile.mk @@ -0,0 +1,60 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +PRJ = ..$/.. +PRJNAME = filter +#PACKAGE = com$/sun$/star$/documentconversion$/DBFilter +TARGET =DBFilter +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk +CLASSDIR!:=$(CLASSDIR)$/$(TARGET) +#USE_UDK_EXTENDED_MANIFESTFILE=TRUE +#USE_EXTENDED_MANIFESTFILE=TRUE +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar +JAVAFILES = $(subst,$(CLASSDIR)$/, $(subst,.class,.java $(JAVACLASSFILES))) +CUSTOMMANIFESTFILE = Manifest +#JARMANIFEST = Manifest + +#JARDIR=$(CLASSDIR) + +JARCOMPRESS = TRUE +JARCLASSDIRS = DBFilter*.class +JARTARGET = $(TARGET).jar + + +# --- Files -------------------------------------------------------- +JAVACLASSFILES=$(CLASSDIR)$/DBFilter.class +#---Manifest ------------------------------------------------------- +#$(OUT)$/class$/$(TARGET)$/META-INF: META-INF +# + $(COPY) $(COPYRECURSE) META-INF $(OUT)$/class$/DBFilter$/META-INF +# --- Targets ------------------------------------------------------ +.INCLUDE : target.mk +$(JAVACLASSFILES) : $(CLASSDIR) + +$(CLASSDIR) : + $(MKDIR) $(CLASSDIR) + + diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/docbooktosoffheadings.xsl b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/docbooktosoffheadings.xsl new file mode 100644 index 000000000000..7bb99da2f735 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/docbooktosoffheadings.xsl @@ -0,0 +1,1725 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + + Copyright 2000, 2010 Oracle and/or its affiliates. + + OpenOffice.org - a multi-platform office productivity suite + + This file is part of OpenOffice.org. + + OpenOffice.org is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + OpenOffice.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details + (a copy is included in the LICENSE file that accompanied this code). + + You should have received a copy of the GNU Lesser General Public License + version 3 along with OpenOffice.org. If not, see + <http://www.openoffice.org/license.html> + for a copy of the LGPLv3 License. + +--> + +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:office="http://openoffice.org/2000/office" xmlns:style="http://openoffice.org/2000/style" xmlns:text="http://openoffice.org/2000/text" xmlns:table="http://openoffice.org/2000/table" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="http://openoffice.org/2000/meta" xmlns:number="http://openoffice.org/2000/datastyle" xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart" xmlns:dr3d="http://openoffice.org/2000/dr3d" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="http://openoffice.org/2000/form" xmlns:script="http://openoffice.org/2000/script" xmlns:config="http://openoffice.org/2001/config" version="1.0" office:class="text" office:version="1.0"> + <xsl:output method="xml" indent="yes" omit-xml-declaration="no"/> + <!--<xsl:output method="xml" version="1.0" encoding="UTF-8" doctype-public="-//OASIS//DTD DocBook XML V4.1.2//EN" doctype-system="http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"/>--> + <xsl:decimal-format name="staff" digit="D"/> + + <xsl:variable name="doc_type"> + <xsl:choose> + <xsl:when test="/article"> + <xsl:text>article</xsl:text> + </xsl:when> + <xsl:when test="/chapter"> + <xsl:text>chapter</xsl:text> + </xsl:when> + </xsl:choose> + </xsl:variable> + + + <xsl:template match="/"> + <xsl:element name="office:document"> + <office:meta> + <meta:generator>StarOffice 6.1 (Solaris Sparc)</meta:generator> + <dc:title> + <xsl:choose> + <xsl:when test="contains( $doc_type, 'chapter' )"> + <xsl:value-of select="/chapter/chapterinfo/title"/> + </xsl:when> + <xsl:when test="contains( $doc_type, 'article' )"> + <xsl:value-of select="/article/articleinfo/title"/> + </xsl:when> + </xsl:choose> + <!--<xsl:value-of select="$doc_type"/>--> + <!--<xsl:value-of select="/article/articleinfo/title"/>--> + + </dc:title> + <dc:description/> + <dc:subject/> + <meta:creation-date>2002-07-15T12:38:53</meta:creation-date> + <dc:date> + <xsl:choose> + <xsl:when test="contains( $doc_type, 'chapter' )"> + <xsl:value-of select="/chapter/chapterinfo/pubdate"/> + </xsl:when> + <xsl:when test="contains( $doc_type, 'article' )"> + <xsl:value-of select="/article/articleinfo/pubdate"/> + </xsl:when> + </xsl:choose> + <!--<xsl:value-of select="article/articleinfo/pubdate"/>--> + + </dc:date> + <dc:language> + <xsl:choose> + <xsl:when test="contains( $doc_type, 'chapter' )"> + <xsl:value-of select="chapter/@lang"/> + </xsl:when> + <xsl:when test="contains( $doc_type, 'article' )"> + <xsl:value-of select="article/@lang"/> + </xsl:when> + </xsl:choose> + <!--<xsl:value-of select="article/@lang"/>--> + + </dc:language> + <meta:editing-cycles>21</meta:editing-cycles> + <meta:editing-duration>P1DT0H11M54S</meta:editing-duration> + <meta:user-defined meta:name="Info 1"/> + <meta:user-defined meta:name="Info 2"/> + <meta:user-defined meta:name="Info 3"/> + <meta:user-defined meta:name="Info 4"/> + <meta:document-statistic meta:table-count="1" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="42" meta:word-count="144" meta:character-count="820"/> + </office:meta> + <office:automatic-styles> + <style:style style:name="fr1" style:family="graphics" style:parent-style-name="Graphics"> + <style:properties style:horizontal-pos="center" style:horizontal-rel="paragraph" style:mirror="none" fo:clip="rect(0cm 0cm 0cm 0cm)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%" draw:blue="0%" draw:gamma="1" draw:color-inversion="false" draw:transparency="-100%" draw:color-mode="standard"/> + </style:style> + <style:style style:name="Table1" style:family="table"> + <style:properties style:width="14.649cm" table:align="margins"/> + </style:style> + <style:style style:name="Table1.A" style:family="table-column"> + <style:properties style:column-width="2.93cm" style:rel-column-width="13107*"/> + </style:style> + <style:style style:name="Table1.A1" style:family="table-cell"> + <style:properties fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="none" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000"/> + </style:style> + <style:style style:name="Table1.E1" style:family="table-cell"> + <style:properties fo:padding="0.097cm" fo:border="0.002cm solid #000000"/> + </style:style> + <style:style style:name="Table1.A2" style:family="table-cell"> + <style:properties fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.002cm solid #000000"/> + </style:style> + <style:style style:name="Table1.E2" style:family="table-cell"> + <style:properties fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000" fo:border-top="none" fo:border-bottom="0.002cm solid #000000"/> + </style:style> + <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Text body" style:list-style-name="Ordered List"/> + <style:style style:name="T1" style:family="text" style:parent-style-name="Source Text"> + <style:properties fo:font-style="normal"/> + </style:style> + <style:page-master style:name="pm1"> + <style:properties fo:page-width="20.999cm" fo:page-height="29.699cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2.54cm" fo:margin-bottom="2.54cm" fo:margin-left="3.175cm" fo:margin-right="3.175cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm"> + <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:properties> + <style:header-style/> + <style:footer-style/> + </style:page-master> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-master-name="pm1"/> + </office:master-styles> + <office:body> + <xsl:call-template name="entities"/> + <xsl:apply-templates/> + </office:body> + </xsl:element> + </xsl:template> + + +<xsl:template name="entities"> + <xsl:element name="text:variable-decls"> + <xsl:for-each select="/descendant::entity"> + <xsl:variable name="entname"><xsl:value-of select="@name"/></xsl:variable> + <xsl:if test="not(preceding::entity[@name = $entname])"> + <xsl:element name="text:variable-decl"> + <xsl:attribute name="text:value-type"> + <xsl:text>string</xsl:text> + </xsl:attribute> + <xsl:attribute name="text:name"> + <xsl:text>entitydecl_</xsl:text><xsl:value-of select="@name"/> + </xsl:attribute> + </xsl:element> + </xsl:if> + </xsl:for-each> + </xsl:element> +</xsl:template> + + + +<xsl:template match="entity"> + <xsl:variable name="entname"><xsl:value-of select="@name"/></xsl:variable> + <xsl:choose> + <xsl:when test="not(preceding::entity[@name = $entname])"> + <xsl:element name="text:variable-set"> + <xsl:attribute name="text:value-type"> + <xsl:text>string</xsl:text> + </xsl:attribute> + <xsl:attribute name="text:name"> + <xsl:text>entitydecl_</xsl:text><xsl:value-of select="@name"/> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:otherwise> + <xsl:element name="text:variable-get"> + <xsl:attribute name="text:value-type"> + <xsl:text>string</xsl:text> + </xsl:attribute> + <xsl:attribute name="text:name"> + <xsl:text>entitydecl_</xsl:text><xsl:value-of select="@name"/> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + +</xsl:template> + + + + <!-- table start --> + + <xsl:template match="table"> + <xsl:variable name="tabletitle"> + <xsl:value-of select="title"/> + </xsl:variable> + <xsl:element name="table:table"> + <xsl:attribute name="table:name"/> + <xsl:attribute name="table:style-name">Table1</xsl:attribute> + <xsl:attribute name="table:name"> + <xsl:value-of select="@id"/> + </xsl:attribute> + <blah>blah</blah> + <xsl:apply-templates/> + </xsl:element> + <xsl:if test="not($tabletitle='')"> + <xsl:element name="text:p"> + <xsl:attribute name="text:style-name">Table</xsl:attribute> + <xsl:value-of select="$tabletitle"/> + </xsl:element> + </xsl:if> + </xsl:template> + + + <xsl:template match="tgroup"> + <xsl:element name="table:table-column"> + <xsl:attribute name="table:style-name">Table1.A</xsl:attribute> + <xsl:choose> + <xsl:when test="@cols >0"> + <xsl:attribute name="table:number-columns-repeated"> + <xsl:value-of select="@cols"/> + </xsl:attribute> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="table:number-columns-repeated"> + <xsl:value-of select="count(child::tbody/row/entry) div count(child::tbody/row) "/> + </xsl:attribute> + </xsl:otherwise> + </xsl:choose> + </xsl:element> + <xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="thead"> + <xsl:element name="table:table-header-rows"> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="tbody"> + <xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="row"> + <xsl:element name="table:table-row"> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="entry"> + <xsl:element name="table:table-cell"> + <xsl:if test="ancestor-or-self::thead"> + <xsl:attribute name="table:style-name">Table1.A1</xsl:attribute> + </xsl:if> + <xsl:if test="not(ancestor-or-self::thead)"> + <xsl:attribute name="table:style-name">Table1.A2</xsl:attribute> + </xsl:if> + <xsl:choose> + <xsl:when test="@spanname"> + <!--<xsl:if test="@spanname">--> + + <xsl:variable name="sname"> + <xsl:value-of select="@spanname"/> + </xsl:variable> + <xsl:attribute name="table:number-columns-spanned"> + <xsl:variable name="colnamestart"> + <xsl:value-of select="ancestor::tgroup/spanspec[@spanname=$sname]/@namest"/> + </xsl:variable> + <xsl:variable name="colnameend"> + <xsl:value-of select="ancestor::tgroup/spanspec[@spanname=$sname]/@nameend"/> + </xsl:variable> + <xsl:variable name="colnumstart"> + <xsl:value-of select="ancestor::tgroup/colspec[@colname=$colnamestart]/@colnum"/> + </xsl:variable> + <xsl:variable name="colnumend"> + <xsl:value-of select="ancestor::tgroup/colspec[@colname=$colnameend]/@colnum"/> + </xsl:variable> + <xsl:value-of select="$colnumend - $colnumstart + 1"/> + </xsl:attribute> + </xsl:when> + <xsl:when test="@namest and @nameend"> + <!--<xsl:if test="@namest and @nameend">--> + + <xsl:variable name="colnamestart"> + <xsl:value-of select="@namest"/> + </xsl:variable> + <xsl:variable name="colnameend"> + <xsl:value-of select="@nameend"/> + </xsl:variable> + <xsl:attribute name="table:number-columns-spanned"> + <xsl:variable name="colnumstart"> + <xsl:value-of select="ancestor::tgroup/colspec[@colname=$colnamestart]/@colnum"/> + </xsl:variable> + <xsl:variable name="colnumend"> + <xsl:value-of select="ancestor::tgroup/colspec[@colname=$colnameend]/@colnum"/> + </xsl:variable> + <xsl:value-of select="$colnumend - $colnumstart + 1"/> + </xsl:attribute> + </xsl:when> + </xsl:choose> + <!-- + <xsl:if test="not(@namest = '' ) "> + <xsl:attribute name="table:number-columns-spanned"> + <xsl:value-of select="(substring-after(@nameend,'c')-substring-after(@namest,'c'))+1"/> + + </xsl:attribute> + </xsl:if> + --> + + <xsl:choose> + <xsl:when test="not(child::para)"> + <xsl:element name="text:p"> + <xsl:if test="ancestor-or-self::thead"> + <xsl:attribute name="text:style-name">Table Heading</xsl:attribute> + </xsl:if> + <xsl:if test="ancestor-or-self::tbody"> + <xsl:attribute name="text:style-name">Table Contents</xsl:attribute> + </xsl:if> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates/> + </xsl:otherwise> + </xsl:choose> + </xsl:element> + </xsl:template> + + + <xsl:template match="subtitle"> + <xsl:choose> + <xsl:when test="parent::table"> + <xsl:apply-templates/> + </xsl:when> + <xsl:when test="parent::informaltable"> + <xsl:apply-templates/> + </xsl:when> + <xsl:otherwise> + <xsl:element name="text:p"> + <xsl:attribute name="text:style-name">Section SubTitle</xsl:attribute> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template match="title"> + <xsl:choose> + <xsl:when test="parent::figure"/> + <xsl:when test="parent::table"/> + <xsl:when test="parent::sect1"/> + <xsl:when test="parent::sect2"/> + <xsl:when test="parent::sect3"/> + <xsl:when test="parent::sect4"/> + <xsl:when test="parent::sect5"/> + <xsl:when test="parent::informaltable"> + <xsl:apply-templates/> + </xsl:when> + <xsl:otherwise> + <xsl:element name="text:p"> + <xsl:choose> + <xsl:when test="parent::appendix"> + <xsl:attribute name="text:style-name">Appendix Title</xsl:attribute> + </xsl:when> + </xsl:choose> + <xsl:apply-templates/> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template match="articleinfo"> + <xsl:element name="text:section"> + <xsl:attribute name="text:style-name">ArticleInfo</xsl:attribute> + <xsl:attribute name="text:name">ArticleInfo</xsl:attribute> + <xsl:if test="/article/articleinfo/subtitle !=''"> + <xsl:element name="text:p"> + <xsl:attribute name="text:style-name">Document SubTitle</xsl:attribute> + <xsl:value-of select="/article/articleinfo/subtitle"/> + </xsl:element> + </xsl:if> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="chapterinfo"> + <xsl:element name="text:section"> + <xsl:attribute name="text:style-name">ChapterInfo</xsl:attribute> + <xsl:attribute name="text:name">ChapterInfo</xsl:attribute> + <xsl:if test="/chapter/chapterinfo/title !='' "> + <xsl:element name="text:p"> + <xsl:attribute name="text:style-name">Document Title</xsl:attribute> + <xsl:value-of select="/chapter/chapterinfo/title"/> + </xsl:element> + <xsl:if test="/chapter/chapterinfo/subtitle !=''"> + <xsl:element name="text:p"> + <xsl:attribute name="text:style-name">Document SubTitle</xsl:attribute> + <xsl:value-of select="/chapter/chapterinfo/subtitle"/> + </xsl:element> + </xsl:if> + </xsl:if> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="appendix"> + <xsl:element name="text:section"> + <xsl:attribute name="text:style-name">Appendix</xsl:attribute> + <xsl:attribute name="text:name">Appendix</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + <!-- +<xsl:template match="author"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="firstname"> + <xsl:element name="text:variable-set"> + <xsl:attribute name="text:name"> + <xsl:if test="ancestor::articleinfo/author"> + <xsl:text disable-output-escaping="yes">articleinfo.author</xsl:text><xsl:value-of select="count(parent::author[preceding-sibling::author])"/><xsl:text disable-output-escaping="yes">.firstname</xsl:text><xsl:value-of select="count(preceding-sibling::firstname)"/> + </xsl:if> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> +</xsl:template> +--> + + <xsl:template match="articleinfo/title | chapterinfo/title"> + <!-- <xsl:element name="text:variable-decls"> + <xsl:element name="text:variable-decl"> + <xsl:attribute name="text:value-type"> + <xsl:text>string</xsl:text> + </xsl:attribute> + <xsl:attribute name="text:name"> + <xsl:text disable-output-escaping="yes">articleinfo.title</xsl:text> + </xsl:attribute> + </xsl:element> + + </xsl:element> + <xsl:element name="text:p"> + <xsl:element name="text:variable-set"> + <xsl:attribute name="text:value-type"> + <xsl:text>string</xsl:text> + </xsl:attribute> + <xsl:attribute name="text:name"> + <xsl:text disable-output-escaping="yes">articleinfo.title</xsl:text> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:element> + --> + </xsl:template> + + + <xsl:template match="articleinfo/title"> + <xsl:element name="text:p"> + <xsl:attribute name="text:style-name">Document Title</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> +</xsl:template> + +<xsl:template match="date"> + <xsl:element name="text:s"/> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>date_</xsl:text><xsl:value-of select="count(preceding::date)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>date_</xsl:text><xsl:value-of select="count(preceding::date)"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:s"/> +</xsl:template> + +<xsl:template match="revision"> + <xsl:element name="text:s"/> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>revision_</xsl:text><xsl:value-of select="count(preceding::revision)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>revision_</xsl:text><xsl:value-of select="count(preceding::revision)"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:s"/> + <xsl:element name="text:s"/> +</xsl:template> + +<xsl:template match="revnumber"> + <xsl:element name="text:s"/> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>revnumber_</xsl:text><xsl:value-of select="count(preceding::revnumber)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>revnumber_</xsl:text><xsl:value-of select="count(preceding::revnumber)"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:s"/> +</xsl:template> + +<xsl:template match="revdescription"> + <xsl:element name="text:s"/> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>revdescription_</xsl:text><xsl:value-of select="count(preceding::revdescription)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>revdescription_</xsl:text><xsl:value-of select="count(preceding::revdescription)"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:s"/> +</xsl:template> + +<xsl:template match="revhistory"> + <xsl:element name="text:p"> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>revhistory_</xsl:text><xsl:value-of select="count(preceding::revhistory)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>revhistory_</xsl:text><xsl:value-of select="count(preceding::revhistory)"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:line-break"/> + </xsl:element> +</xsl:template> + +<xsl:template match="legalnotice"> + <xsl:element name="text:p"> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>legalnotice_</xsl:text><xsl:value-of select="count(preceding::legalnotice)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>legalnotice_</xsl:text><xsl:value-of select="count(preceding::legalnotice)"/> + </xsl:attribute> + </xsl:element> + </xsl:element> +</xsl:template> + +<xsl:template match="legalnotice/title"> + <xsl:element name="text:s"/> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>title_</xsl:text><xsl:value-of select="count(preceding::legalnotice/title)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>title_</xsl:text><xsl:value-of select="count(preceding::legalnotice/title)"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:s"/> +</xsl:template> + +<xsl:template match="para[ancestor::articleinfo]"> + <xsl:element name="text:s"/> + + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>para_</xsl:text><xsl:value-of select="count(preceding::para[ancestor::articleinfo])"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>para_</xsl:text><xsl:value-of select="count(preceding::para[ancestor::articleinfo])"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:s"/> +</xsl:template> + + +<xsl:template match="articleinfo/subtitle"> + <xsl:element name="text:p"> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>subtitle_</xsl:text><xsl:value-of select="count(preceding::articleinfo/subtitle)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>subtitle_</xsl:text><xsl:value-of select="count(preceding::articleinfo/subtitle)"/> + </xsl:attribute> + </xsl:element> + </xsl:element> +</xsl:template> + +<xsl:template match="articleinfo/edition"> + <xsl:element name="text:p"> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>edition_</xsl:text><xsl:value-of select="count(preceding::articleinfo/edition)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>edition_</xsl:text><xsl:value-of select="count(preceding::articleinfo/edition)"/> + </xsl:attribute> + </xsl:element> + </xsl:element> +</xsl:template> + +<xsl:template match="articleinfo/releaseinfo"> + <xsl:element name="text:p"> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>releaseinfo_</xsl:text><xsl:value-of select="count(preceding::articleinfo/releaseinfo)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>releaseinfo_</xsl:text><xsl:value-of select="count(preceding::articleinfo/releaseinfo)"/> + </xsl:attribute> + </xsl:element> + </xsl:element> +</xsl:template> + + +<xsl:template match="author/firstname"> + <xsl:element name="text:s"/> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>firstname_</xsl:text><xsl:value-of select="count(preceding::author/firstname)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>firstname_</xsl:text><xsl:value-of select="count(preceding::author/firstname)"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:s"/> + +</xsl:template> + + + +<xsl:template match="year[ancestor::articleinfo]"> + <xsl:element name="text:s"/> + + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>year_</xsl:text><xsl:value-of select="count(preceding::year[ancestor::articleinfo])"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>year_</xsl:text><xsl:value-of select="count(preceding::year[ancestor::articleinfo])"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:s"/> + +</xsl:template> + +<xsl:template match="authorgroup"> + <xsl:element name="text:p"> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>authorgroup_</xsl:text><xsl:value-of select="count(preceding::authorgroup)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>authorgroup_</xsl:text><xsl:value-of select="count(preceding::authorgroup)"/> + </xsl:attribute> + </xsl:element> + </xsl:element> +</xsl:template> + +<xsl:template match="articleinfo/copyright/holder"> + <xsl:element name="text:s"/> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>holder_</xsl:text><xsl:value-of select="count(preceding::articleinfo/copyright/holder)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>holder_</xsl:text><xsl:value-of select="count(preceding::articleinfo/copyright/holder)"/> + </xsl:attribute> + </xsl:element> + <!--<xsl:element name="text:s"/>--> + <xsl:element name="text:line-break"/> +</xsl:template> + +<xsl:template match="articleinfo/copyright"> + <xsl:element name="text:p"> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>copyright_</xsl:text><xsl:value-of select="count(preceding::articleinfo/copyright)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>copyright_</xsl:text><xsl:value-of select="count(preceding::articleinfo/copyright)"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:s"/> + </xsl:element> +</xsl:template> + + +<xsl:template name="affiliation"> + <xsl:element name="text:s"/> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>affiliation_</xsl:text><xsl:value-of select="count(preceding::affiliation)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>affiliation_</xsl:text><xsl:value-of select="count(preceding::affiliation)"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:s"/> +</xsl:template> + +<xsl:template match="author/affiliation/address"> + <xsl:element name="text:p"> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>address_</xsl:text><xsl:value-of select="count(preceding::author/affiliation/address)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>address_</xsl:text><xsl:value-of select="count(preceding::author/affiliation/address)"/> + </xsl:attribute> + </xsl:element> +</xsl:element> +</xsl:template> + +<xsl:template match="authorgroup"> + <xsl:element name="text:p"> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>authorgroup_</xsl:text><xsl:value-of select="count(preceding::authorgroup)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>authorgroup_</xsl:text><xsl:value-of select="count(preceding::authorgroup)"/> + </xsl:attribute> + </xsl:element> +</xsl:element> +</xsl:template> + + +<xsl:template match="author"> + <xsl:element name="text:s"/> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>author_</xsl:text><xsl:value-of select="count(preceding::author)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>author_</xsl:text><xsl:value-of select="count(preceding::author)"/> + </xsl:attribute> + </xsl:element> + <!--<xsl:element name="text:s"/>--> + <xsl:element name="text:line-break"/> +</xsl:template> + +<xsl:template match="author/affiliation"> + <xsl:element name="text:s"/> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>affiliation_</xsl:text><xsl:value-of select="count(preceding::author/affiliation)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>affiliation_</xsl:text><xsl:value-of select="count(preceding::author/affiliation)"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:s"/> +</xsl:template> + +<xsl:template match="author/affiliation/address"> + <xsl:element name="text:s"/> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>address_</xsl:text><xsl:value-of select="count(preceding::author/affiliation/address)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>address_</xsl:text><xsl:value-of select="count(preceding::author/affiliation/address)"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:s"/> +</xsl:template> + + +<xsl:template match="email[ancestor::articleinfo]"> + <xsl:element name="text:s"/> + + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>email_</xsl:text><xsl:value-of select="count(preceding::email[ancestor::articleinfo])"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>email_</xsl:text><xsl:value-of select="count(preceding::email[ancestor::articleinfo])"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:s"/> + +</xsl:template> + +<xsl:template match="author/affiliation/orgname"> + <xsl:element name="text:s"/> + + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>orgname_</xsl:text><xsl:value-of select="count(preceding::author/affiliation/orgname)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>orgname_</xsl:text><xsl:value-of select="count(preceding::author/affiliation/orgname)"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:s"/> + +</xsl:template> + + +<xsl:template match="author/surname"> + <xsl:element name="text:s"/> + + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>surname_</xsl:text><xsl:value-of select="count(preceding::author/surname)"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>surname_</xsl:text><xsl:value-of select="count(preceding::author/surname)"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="text:s"/> + + +</xsl:template> + + + + <xsl:template match="para"> + <xsl:choose> + <xsl:when test="ancestor::varlistentry"> + <xsl:element name="text:p"> + <xsl:attribute name="text:style-name">VarList Term</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:otherwise> + <xsl:element name="text:p"> + <xsl:choose> + <xsl:when test="ancestor-or-self::footnote"> + <xsl:attribute name="text:style-name"> + <xsl:text>Footnote</xsl:text> + </xsl:attribute> + </xsl:when> + <xsl:when test="ancestor-or-self::informaltable"> + <xsl:if test="ancestor-or-self::informaltable"> + <xsl:attribute name="text:style-name">Table Contents</xsl:attribute> + </xsl:if> + <xsl:if test="ancestor-or-self::thead "> + <xsl:attribute name="text:style-name">Table Heading</xsl:attribute> + </xsl:if> + </xsl:when> + <xsl:when test="ancestor-or-self::table"> + <xsl:if test="ancestor-or-self::table"> + <xsl:attribute name="text:style-name">Table Contents</xsl:attribute> + </xsl:if> + <xsl:if test="ancestor-or-self::thead "> + <xsl:attribute name="text:style-name">Table Heading</xsl:attribute> + </xsl:if> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="text:style-name">Text body</xsl:attribute> + </xsl:otherwise> + </xsl:choose> + <xsl:choose> + <xsl:when test="@id"> + <xsl:call-template name="test.id"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates/> + </xsl:otherwise> + </xsl:choose> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template match="section"> + <xsl:element name="text:h"> + <xsl:attribute name="text:level"> + <xsl:value-of select="count(ancestor-or-self::section) "/> + </xsl:attribute> + <xsl:value-of select="child::title"/> + </xsl:element> + <xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="abstract"> + <xsl:element name="text:h"> + <xsl:attribute name="text:level">1</xsl:attribute> + <xsl:text>abstract</xsl:text> + </xsl:element> + <xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="appendix"> + <xsl:element name="text:h"> + <xsl:attribute name="text:level">1</xsl:attribute> + <xsl:text>appendix</xsl:text> + </xsl:element> + <xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="sect1"> + <xsl:element name="text:h"> + <xsl:attribute name="text:level">1</xsl:attribute> + <xsl:choose> + <xsl:when test="@id"> + <xsl:call-template name="test.id"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="child::title"/> + </xsl:otherwise> + </xsl:choose> + </xsl:element> + <xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="sect2"> + <xsl:element name="text:h"> + <xsl:attribute name="text:level">2</xsl:attribute> + <xsl:choose> + <xsl:when test="@id"> + <xsl:call-template name="test.id"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="child::title"/> + </xsl:otherwise> + </xsl:choose> + </xsl:element> + <xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="sect3"> + <xsl:element name="text:h"> + <xsl:attribute name="text:level">3</xsl:attribute> + <xsl:choose> + <xsl:when test="@id"> + <xsl:call-template name="test.id"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="child::title"/> + </xsl:otherwise> + </xsl:choose> + </xsl:element> + <xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="sect4"> + <xsl:element name="text:h"> + <xsl:attribute name="text:level">4</xsl:attribute> + <xsl:choose> + <xsl:when test="@id"> + <xsl:call-template name="test.id"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="child::title"/> + </xsl:otherwise> + </xsl:choose> + </xsl:element> + <xsl:apply-templates/> + </xsl:template> + <!--<xsl:template match="sect5"> + <xsl:element name="text:section"> + <xsl:attribute name="text:style-name">Sect1</xsl:attribute> + <xsl:attribute name="text:name"><xsl:value-of select="@id"/></xsl:attribute> + <xsl:apply-templates/> + </xsl:element> +</xsl:template>--> + + <xsl:template match="informaltable"> + <xsl:element name="table:table"> + <xsl:attribute name="table:name"/> + <xsl:attribute name="table:style-name">Table1</xsl:attribute> + <xsl:attribute name="table:name"> + <xsl:value-of select="@id"/> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + <xsl:template match="indexterm"/> + + + <xsl:template match="figure"> + <xsl:apply-templates/> + </xsl:template> + <!-- lists Section --> + + <xsl:template match="itemizedlist"> + <xsl:element name="text:unordered-list"> + <xsl:attribute name="text:style-name">UnOrdered List</xsl:attribute> + <xsl:attribute name="text:continue-numbering">false</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="variablelist"> + <xsl:element name="text:unordered-list"> + <xsl:attribute name="text:style-name">Var List</xsl:attribute> + <xsl:attribute name="text:continue-numbering">false</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="orderedlist"> + <xsl:element name="text:ordered-list"> + <xsl:attribute name="text:style-name">Ordered List</xsl:attribute> + <xsl:attribute name="text:continue-numbering">false</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="term"> + <xsl:if test="parent::varlistentry"> + <text:list-item> + <xsl:element name="text:p"> + <xsl:attribute name="text:style-name">VarList Term</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </text:list-item> + </xsl:if> + </xsl:template> + + + <xsl:template match="listitem"> + <xsl:choose> + <xsl:when test="parent::varlistentry"> + <text:list-item> + <xsl:apply-templates/> + </text:list-item> + </xsl:when> + <xsl:otherwise> + <text:list-item> + <xsl:apply-templates/> + </text:list-item> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + <!-- end of lists--> + + <xsl:template match="menuchoice"> + <xsl:variable name="pos"><xsl:value-of select="count(preceding::menuchoice)"/></xsl:variable> + <xsl:element name="text:bookmark-start"> + <xsl:attribute name="text:name"> + <xsl:text>menuchoice_</xsl:text><xsl:value-of select="$pos"/> + </xsl:attribute> + </xsl:element> + <xsl:apply-templates/> + <xsl:element name="text:bookmark-end"> + <xsl:attribute name="text:name"> + <xsl:text>menuchoice_</xsl:text><xsl:value-of select="$pos"/> + </xsl:attribute> + </xsl:element> + </xsl:template> + + + <xsl:template match="guimenuitem"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">GuiMenuItem</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="guibutton"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">GuiButton</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="guisubmenu"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">GuiSubMenu</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + +<!-- Change Made By Kevin Fowlks (fowlks@msu.edu) June 4th, 2003 --> + <xsl:template match="emphasis"> + <xsl:element name="text:span"> + <xsl:choose> + <xsl:when test="@role"> + <xsl:attribute name="text:style-name">Emphasis Bold</xsl:attribute> + <xsl:apply-templates/> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="text:style-name">Emphasis</xsl:attribute> + <xsl:apply-templates/> + </xsl:otherwise> + </xsl:choose> + </xsl:element> + </xsl:template> + +<!-- Change Made By Kevin Fowlks (fowlks@msu.edu) June 16th, 2003 --> + <xsl:template match="quote"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">Citation</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + <xsl:template match="guimenu"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">GuiMenu</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="guisubmenu"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">GuiSubMenu</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="guilabel"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">GuiLabel</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="guibutton"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">GuiButton</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="keycap"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">KeyCap</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="keysym"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">KeySym</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="keycombo"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">KeyCombo</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="command"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">Command</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="application"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">Application</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="filename"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">FileName</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="systemitem"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">SystemItem</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="computeroutput"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name">ComputerOutput</xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="inlinegraphic"> + <xsl:element name="draw:image"> + <xsl:attribute name="draw:style-name"> + <xsl:text>fr1</xsl:text> + </xsl:attribute> + <xsl:attribute name="draw:name"/> + <xsl:attribute name="text:anchor-type"/> + <xsl:attribute name="draw:z-index"/> + <xsl:attribute name="xlink:href"> + <xsl:value-of select="@fileref"/> + </xsl:attribute> + <xsl:attribute name="xlink:type"/> + <xsl:attribute name="svg:width"> + <!--<xsl:value-of select="@width"/>--> + + <xsl:text>1cm</xsl:text> + </xsl:attribute> + <xsl:attribute name="svg:height"> + <xsl:text>1cm</xsl:text> + </xsl:attribute> + <xsl:attribute name="xlink:show"> + <xsl:text>embed</xsl:text> + </xsl:attribute> + <xsl:attribute name="xlink:actuate"> + <xsl:text>onLoad</xsl:text> + </xsl:attribute> + <xsl:attribute name="draw:filter-name"> + <xsl:text disable-output-escaping="yes"><All formats></xsl:text> + </xsl:attribute> + </xsl:element> + </xsl:template> + + + <xsl:template match="footnote"> + <xsl:element name="text:footnote"> + <!--<xsl:element name="text:footnote-citation">Aidan</xsl:element>--> + + <xsl:element name="text:footnote-body"> + <xsl:apply-templates/> + </xsl:element> + </xsl:element> + </xsl:template> + + + <xsl:template match="highlight"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name"> + <xsl:text>Highlight</xsl:text> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="ulink"> + <xsl:element name="text:a"> + <xsl:attribute name="xlink:type"> + <xsl:text>simple</xsl:text> + </xsl:attribute> + <xsl:attribute name="xlink:href"> + <xsl:value-of select="@url"/> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="link"> + <xsl:element name="text:a"> + <xsl:attribute name="xlink:type"> + <xsl:text>simple</xsl:text> + </xsl:attribute> + <xsl:attribute name="xlink:href"> + <xsl:text>#</xsl:text> + <xsl:value-of select="@linkend"/> + <xsl:text>%7Cregion</xsl:text> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="olink"> + <xsl:element name="text:a"> + <xsl:attribute name="xlink:type"> + <xsl:text>simple</xsl:text> + </xsl:attribute> + <xsl:attribute name="xlink:href"> + <xsl:value-of select="@targetdocent"/> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + <!-- xref maps to reference-ref i.e an OOo insert reference + xref is an empty element, reference-ref spans the object to be referenced --> + <xsl:template match="xref"> + <xsl:element name="text:reference-ref"> + <xsl:attribute name="text:reference-format"> + <xsl:text>text</xsl:text> + </xsl:attribute> + <xsl:attribute name="text:ref-name"> + <xsl:value-of select="@linkend"/> + </xsl:attribute> + </xsl:element> + </xsl:template> + + + <!-- the DocBook elements that have been "xreffed" contain an ID attribute that is linked to by an xref @linkend or @endterm --> + <!-- the @id can also be pointed to by an indexterm --> + + <xsl:template name="test.id"> + <xsl:if test="@id"> + <xsl:variable name="id.val"> + <xsl:value-of select="@id"/> + </xsl:variable> + + <xsl:element name="text:reference-mark-start"> + <xsl:attribute name="text:name"> + <xsl:value-of select="@id"/> + </xsl:attribute> + </xsl:element> + + <xsl:choose> + <xsl:when test="self::para"> + <xsl:apply-templates/> + </xsl:when> + <xsl:otherwise> + <!-- sect* --> + <xsl:value-of select="child::title"/> + </xsl:otherwise> + </xsl:choose> + + <xsl:element name="text:reference-mark-end"> + <xsl:attribute name="text:name"> + <xsl:value-of select="@id"/> + </xsl:attribute> + </xsl:element> + + </xsl:if> + </xsl:template> + + + <xsl:template match="indexterm"> + <xsl:if test="@class = 'startofrange'"> + <xsl:element name="text:alphabetical-index-mark-start"> + <xsl:attribute name="text:id"> + <xsl:value-of select="@id"/> + </xsl:attribute> + <!--<xsl:if test="primary">--> + + <xsl:attribute name="text:key1"> + <xsl:value-of select="primary"/> + </xsl:attribute> + <!--</xsl:if>--> + + <xsl:if test="secondary">--> + <xsl:attribute name="text:key2"> + <xsl:value-of select="secondary"/> + </xsl:attribute> + </xsl:if> + </xsl:element> + </xsl:if> + <xsl:if test="@class = 'endofrange'"> + <xsl:element name="text:alphabetical-index-mark-end"> + <xsl:attribute name="text:id"> + <xsl:value-of select="@startref"/> + </xsl:attribute> + </xsl:element> + </xsl:if> + </xsl:template> + + + <xsl:template match="index"> + <xsl:element name="text:alphabetical-index"> + <xsl:attribute name="text:style-name"> + <xsl:text disable-output-escaping="yes">Sect1</xsl:text> + </xsl:attribute> + <xsl:attribute name="text:protected"> + <xsl:text disable-output-escaping="yes">true</xsl:text> + </xsl:attribute> + <xsl:attribute name="text:name"> + <xsl:value-of select="title"/> + </xsl:attribute> + <xsl:element name="text:alphabetical-index-source"> + <xsl:attribute name="text:main-entry-style-name"> + <xsl:text disable-output-escaping="yes">Main index entry</xsl:text> + </xsl:attribute> + <xsl:attribute name="text:sort-algorithm"> + <xsl:text disable-output-escaping="yes">alphanumeric</xsl:text> + </xsl:attribute> + <xsl:attribute name="fo:language"> + <xsl:text disable-output-escaping="yes">en</xsl:text> + </xsl:attribute> + <xsl:attribute name="fo:country"> + <xsl:text disable-output-escaping="yes">IE</xsl:text> + </xsl:attribute> + <xsl:element name="text:index-title-template"> + <xsl:attribute name="text:style-name">Index Heading</xsl:attribute> + <xsl:value-of select="title"/> + </xsl:element> + <xsl:element name="text:alphabetical-index-entry-template"> + <xsl:attribute name="text:outline-level"> + <xsl:text disable-output-escaping="yes">separator</xsl:text> + </xsl:attribute> + <xsl:attribute name="text:style-name"> + <xsl:text disable-output-escaping="yes">Index Separator</xsl:text> + </xsl:attribute> + <xsl:element name="text:index-entry-text"/> + </xsl:element> + <xsl:element name="text:alphabetical-index-entry-template"> + <xsl:attribute name="text:outline-level"> + <xsl:text disable-output-escaping="yes">1</xsl:text> + </xsl:attribute> + <xsl:attribute name="text:style-name"> + <xsl:text disable-output-escaping="yes">Index 1</xsl:text> + </xsl:attribute> + <xsl:element name="text:index-entry-text"/> + <xsl:element name="text:index-entry-tab-stop"> + <xsl:attribute name="style:type"> + <xsl:text disable-output-escaping="yes">left</xsl:text> + </xsl:attribute> + <xsl:attribute name="style:position"> + <xsl:text disable-output-escaping="yes">0cm</xsl:text> + </xsl:attribute> + <xsl:attribute name="style:leader-char"> + <xsl:text disable-output-escaping="yes"/> + </xsl:attribute> + </xsl:element> + </xsl:element> + <xsl:element name="text:alphabetical-index-entry-template"> + <xsl:attribute name="text:outline-level"> + <xsl:text disable-output-escaping="yes">2</xsl:text> + </xsl:attribute> + <xsl:attribute name="text:style-name"> + <xsl:text disable-output-escaping="yes">Index 2</xsl:text> + </xsl:attribute> + <xsl:element name="text:index-entry-text"/> + <xsl:element name="text:index-entry-tab-stop"> + <xsl:attribute name="style:type"> + <xsl:text disable-output-escaping="yes">left</xsl:text> + </xsl:attribute> + <xsl:attribute name="style:position"> + <xsl:text disable-output-escaping="yes">0cm</xsl:text> + </xsl:attribute> + <xsl:attribute name="style:leader-char"> + <xsl:text disable-output-escaping="yes"/> + </xsl:attribute> + </xsl:element> + </xsl:element> + <xsl:element name="text:alphabetical-index-entry-template"> + <xsl:attribute name="text:outline-level"> + <xsl:text disable-output-escaping="yes">3</xsl:text> + </xsl:attribute> + <xsl:attribute name="text:style-name"> + <xsl:text disable-output-escaping="yes">Index 3</xsl:text> + </xsl:attribute> + <xsl:element name="text:index-entry-text"/> + <xsl:element name="text:index-entry-tab-stop"> + <xsl:attribute name="style:type"> + <xsl:text disable-output-escaping="yes">left</xsl:text> + </xsl:attribute> + <xsl:attribute name="style:position"> + <xsl:text disable-output-escaping="yes">0cm</xsl:text> + </xsl:attribute> + <xsl:attribute name="style:leader-char"> + <xsl:text disable-output-escaping="yes"/> + </xsl:attribute> + </xsl:element> + </xsl:element> + </xsl:element> + + <xsl:element name="text:index-body"> + <xsl:element name="text:index-title"> + <xsl:attribute name="text:style-name"> + <xsl:text disable-output-escaping="yes">Sect1</xsl:text> + </xsl:attribute> + <xsl:attribute name="text:name"> + <xsl:text disable-output-escaping="yes">Alphabetical Index1_Head</xsl:text> + </xsl:attribute> + <xsl:element name="text:p"> + <xsl:attribute name="text:style-name"> + <xsl:text disable-output-escaping="yes">Index Heading</xsl:text> + </xsl:attribute> + <xsl:value-of select="title"/> + </xsl:element> + </xsl:element> + <xsl:apply-templates select="indexentry"/> + </xsl:element> + </xsl:element> + </xsl:template> + + + <xsl:template match="indexentry"> + <xsl:element name="text:p"> + <xsl:attribute name="text:style-name"> + <xsl:text disable-output-escaping="yes">Index 1</xsl:text> + </xsl:attribute> + <xsl:value-of select="primaryie"/> + <xsl:element name="text:tab-stop"/> + </xsl:element> + <xsl:if test="secondaryie"> + <xsl:element name="text:p"> + <xsl:attribute name="text:style-name"> + <xsl:text disable-output-escaping="yes">Index 2</xsl:text> + </xsl:attribute> + <xsl:value-of select="secondaryie"/> + <xsl:element name="text:tab-stop"/> + </xsl:element> + </xsl:if> + </xsl:template> + + + <xsl:template match="note"> + <office:annotation> + <text:p> + <xsl:apply-templates/> + </text:p> + </office:annotation> + </xsl:template> + + + <xsl:template match="imageobject"> + <xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="textobject"/> + + + <xsl:template match="caption"> + <xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="imagedata"> + <xsl:element name="draw:image"> + <xsl:attribute name="draw:style-name"> + <xsl:text>fr1</xsl:text> + </xsl:attribute> + <xsl:attribute name="draw:name"/> + <xsl:attribute name="text:anchor-type"/> + <xsl:attribute name="draw:z-index"/> + <xsl:attribute name="xlink:href"> + <xsl:value-of select="@fileref"/> + </xsl:attribute> + <xsl:attribute name="xlink:type"/> + <xsl:attribute name="svg:width"> + <!--<xsl:value-of select="@width"/>--> + + <xsl:text>1cm</xsl:text> + </xsl:attribute> + <xsl:attribute name="svg:height"> + <xsl:text>1cm</xsl:text> + </xsl:attribute> + <xsl:attribute name="xlink:show"> + <xsl:text>embed</xsl:text> + </xsl:attribute> + <xsl:attribute name="xlink:actuate"> + <xsl:text>onLoad</xsl:text> + </xsl:attribute> + <xsl:attribute name="draw:filter-name"> + <xsl:text disable-output-escaping="yes"><All formats></xsl:text> + </xsl:attribute> + </xsl:element> + </xsl:template> + + + <xsl:template match="audioobject"> + <xsl:element name="draw:plugin"> + <xsl:attribute name="draw:style-name"> + <xsl:text>fr1</xsl:text> + </xsl:attribute> + <xsl:attribute name="draw:name"/> + <xsl:attribute name="text:anchor-type"/> + <xsl:attribute name="draw:z-index"/> + <xsl:attribute name="xlink:href"> + <xsl:value-of select="@fileref"/> + </xsl:attribute> + <xsl:attribute name="xlink:type"/> + <xsl:attribute name="svg:width"> + <!--<xsl:value-of select="@width"/>--> + + <xsl:text>1cm</xsl:text> + </xsl:attribute> + <xsl:attribute name="svg:height"> + <xsl:text>1cm</xsl:text> + </xsl:attribute> + <xsl:attribute name="xlink:show"> + <xsl:text>embed</xsl:text> + </xsl:attribute> + <xsl:attribute name="xlink:actuate"> + <xsl:text>onLoad</xsl:text> + </xsl:attribute> + <xsl:attribute name="draw:filter-name"> + <xsl:text disable-output-escaping="yes"><All formats></xsl:text> + </xsl:attribute> + </xsl:element> + </xsl:template> + + + <xsl:template match="remark"> + <xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="mediaobject"> + <xsl:element name="text:p"> + <xsl:attribute name="text:style-name"> + <xsl:text>Mediaobject</xsl:text> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="superscript"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name"> + <xsl:text>SuperScript</xsl:text> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="subscript"> + <xsl:element name="text:span"> + <xsl:attribute name="text:style-name"> + <xsl:text>SubScript</xsl:text> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="comment()"> + <xsl:element name="text:p"> + <xsl:attribute name="text:style-name">XMLComment</xsl:attribute> + <xsl:value-of select="."/> + </xsl:element> + </xsl:template> +</xsl:stylesheet> diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/literallayout.java b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/literallayout.java new file mode 100644 index 000000000000..c2dbc2396d94 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/literallayout.java @@ -0,0 +1,135 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package org.openoffice.xmerge.converter.xml.xslt.docbook; +import java.lang.String; + + +public class literallayout{ + + public static String RemoveSpaces(String test){ + System.out.println("\nWorking... Length=" +test.length()); + int i=0; + int paraBreak=10000; + String result=""; + char data[]={10}; + char tab[]={13}; + if(test!=null){ + String strArr[]= test.split(new String(data)); + test=""; + + while (i< strArr.length ){ + //System.out.println("Trying "+ i); + + if (test.length()+strArr[i].length()> paraBreak){ + test=test.concat("</text:p><text:p text:style-name=\"Preformatted Text\" text:name=\"Preformatted Text\">"); + paraBreak+=10000; + } + strArr[i]=needsMask(strArr[i]).concat("<text:line-break/>"); + strArr[i]=needsSecondMask(strArr[i]); + test=test.concat(strArr[i]); + i++; + } + + System.out.println(test.length()); + + } + else{ + test=""; + } + System.out.println("\nDone"); + return test; + } + + public static String needsMask(String origString){ + if (origString.indexOf("&")!=-1){ + origString=replaceStr(origString,"&","&"); + } + if (origString.indexOf("\"")!=-1){ + origString=replaceStr(origString,"\"","""); + } + if (origString.indexOf("<")!=-1){ + origString=replaceStr(origString,"<","<"); + } + if (origString.indexOf(">")!=-1){ + origString=replaceStr(origString,">",">"); + } + return origString; + + } + + public static String needsSecondMask(String origString){ + char data[]={10}; + char tab[]={9}; + if (origString.indexOf(" ")!=-1){ + origString=replaceStr(origString," "," <text:s/>"); + } + if (origString.indexOf(new String(tab))!=-1){ + origString=replaceStr(origString,new String(tab),"<text:tab-stop/>"); + } + + return origString; + + } + + public static String replaceStr(String origString, String origChar, String replaceChar){ + String tmp=""; + int index=origString.indexOf(origChar); + if(index !=-1){ + while (index !=-1){ + String first =origString.substring(0,index); + first=first.concat(replaceChar); + tmp=tmp.concat(first); + origString=origString.substring(index+1,origString.length()); + index=origString.indexOf(origChar); + if(index==-1) { + tmp=tmp.concat(origString); + } + + } + + } + return tmp; + } + + + private static String replace(String test){ + int i=0; + String result=""; + if (test.indexOf(" ",i)!=-1){ + while (test.indexOf(" ",i)!=-1){ + result=result.concat(test.substring(0,test.indexOf(" ",i))); + result=result.concat(" <text:s/>"); + i=test.indexOf(" ",i)+2; + } + return result; + } + else{ + return test; + } + } + +} diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/sofftodocbookheadings_article.xsl b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/sofftodocbookheadings_article.xsl new file mode 100644 index 000000000000..649869eca225 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/sofftodocbookheadings_article.xsl @@ -0,0 +1,848 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + + Copyright 2000, 2010 Oracle and/or its affiliates. + + OpenOffice.org - a multi-platform office productivity suite + + This file is part of OpenOffice.org. + + OpenOffice.org is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + OpenOffice.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details + (a copy is included in the LICENSE file that accompanied this code). + + You should have received a copy of the GNU Lesser General Public License + version 3 along with OpenOffice.org. If not, see + <http://www.openoffice.org/license.html> + for a copy of the LGPLv3 License. + +--> + +<xsl:stylesheet version="1.0" xmlns:style="http://openoffice.org/2000/style" xmlns:text="http://openoffice.org/2000/text" xmlns:office="http://openoffice.org/2000/office" xmlns:table="http://openoffice.org/2000/table" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="http://openoffice.org/2000/meta" xmlns:number="http://openoffice.org/2000/datastyle" xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart" xmlns:dr3d="http://openoffice.org/2000/dr3d" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="http://openoffice.org/2000/form" xmlns:script="http://openoffice.org/2000/script" xmlns:config="http://openoffice.org/2001/config" office:class="text" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="office meta table number dc fo xlink chart math script xsl draw svg dr3d form config text style"> + + <xsl:key name='headchildren' match="text:p | text:alphabetical-index | table:table | text:span | text:ordered-list | office:annotation | text:unordered-list | text:footnote | text:a | text:list-item | draw:plugin | draw:text-box | text:footnote-body | text:section" + use="generate-id((..|preceding-sibling::text:h[@text:level='1']|preceding-sibling::text:h[@text:level='2']|preceding-sibling::text:h[@text:level='3']|preceding-sibling::text:h[@text:level='4']|preceding-sibling::text:h[@text:level='5'])[last()])"/> + + <xsl:key name="children" match="text:h[@text:level='2']" + use="generate-id(preceding-sibling::text:h[@text:level='1'][1])"/> + + <xsl:key name="children" match="text:h[@text:level='3']" + use="generate-id(preceding-sibling::text:h[@text:level='2' or @text:level='1'][1])"/> + + <xsl:key name="children" match="text:h[@text:level='4']" + use="generate-id(preceding-sibling::text:h[@text:level='3' or @text:level='2' or @text:level='1'][1])"/> + + <xsl:key name="children" match="text:h[@text:level='5']" + use="generate-id(preceding-sibling::text:h[@text:level='4' or @text:level='3' or @text:level='2' or @text:level='1'][1])"/> + + <xsl:key name="secondary_children" match="text:p[@text:style-name = 'Index 2']" + use="generate-id(preceding-sibling::text:p[@text:style-name = 'Index 1'][1])"/> + +<!-- --> + <xsl:template match="/office:document"> + <xsl:text disable-output-escaping="yes"><!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [ + </xsl:text> + <xsl:for-each select="descendant::text:variable-decl"> + <xsl:variable name="name"><xsl:value-of select="@text:name"/></xsl:variable> + <xsl:if test="contains(@text:name,'entitydecl')"> + <xsl:text disable-output-escaping="yes"><!ENTITY </xsl:text><xsl:value-of select="substring-after(@text:name,'entitydecl_')"/><xsl:text> "</xsl:text><xsl:value-of select="/descendant::text:variable-set[@text:name= $name][1]"/><xsl:text disable-output-escaping="yes">"></xsl:text> + </xsl:if> + </xsl:for-each> + + <xsl:text disable-output-escaping="yes">]></xsl:text> + <article> + <xsl:attribute name="lang"> + <xsl:value-of select="/office:document/office:meta/dc:language"/> + </xsl:attribute> + <xsl:apply-templates/> + </article> + </xsl:template> + + + <xsl:template match="text:section"> + <xsl:choose> + <xsl:when test="@text:name='ArticleInfo'"> + <articleinfo> + <xsl:apply-templates/> + </articleinfo> + </xsl:when> + <xsl:when test="@text:name='Abstract'"> + <abstract> + <xsl:apply-templates/> + </abstract> + </xsl:when> + <xsl:when test="@text:name='Appendix'"> + <appendix> + <xsl:apply-templates/> + </appendix> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="sectvar"><xsl:text>sect</xsl:text><xsl:value-of select="count(ancestor::text:section)+1"/></xsl:variable> + <xsl:variable name="idvar"><xsl:text> id="</xsl:text><xsl:value-of select="@text:name"/><xsl:text>"</xsl:text></xsl:variable> + <xsl:text disable-output-escaping="yes"><</xsl:text><xsl:value-of select="$sectvar"/><xsl:value-of select="$idvar"/><xsl:text disable-output-escaping="yes">></xsl:text> + <xsl:apply-templates/> + <xsl:text disable-output-escaping="yes"></</xsl:text><xsl:value-of select="$sectvar"/><xsl:text disable-output-escaping="yes">></xsl:text> + </xsl:otherwise> +</xsl:choose> + + </xsl:template> + + <xsl:template match="text:h[@text:level='1']"> + <xsl:choose> + <xsl:when test=".='Abstract'"> + <abstract> + <xsl:apply-templates select="key('headchildren', generate-id())"/> + <xsl:apply-templates select="key('children', generate-id())"/> + </abstract> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="make-section"> + <xsl:with-param name="current" select="@text:level"/> + <xsl:with-param name="prev" select="1"/> + </xsl:call-template> + <!--<sect1> + <title> + <xsl:apply-templates/> + </title> + <xsl:apply-templates select="key('headchildren', generate-id())"/> + <xsl:apply-templates select="key('children', generate-id())"/> + </sect1>--> + + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template match="text:h[@text:level='2'] | text:h[@text:level='3']| text:h[@text:level='4'] | text:h[@text:level='5']"> + <xsl:variable name="level" select="@text:level"/> + <xsl:call-template name="make-section"> + <xsl:with-param name="current" select="$level"/> + <xsl:with-param name="prev" select="preceding-sibling::text:h[@text:level < $level][1]/@text:level "/> + </xsl:call-template> + </xsl:template> + + + <xsl:template name="make-section"> + <xsl:param name="current"/> + <xsl:param name="prev"/> + <xsl:choose> + <xsl:when test="$current > $prev+1"> + <xsl:variable name="sect.element"> + <xsl:text disable-output-escaping="yes">sect</xsl:text> + <xsl:value-of select="$prev +1"/> + </xsl:variable> + <!--<xsl:text disable-output-escaping="yes"><sect</xsl:text><xsl:value-of select="$prev +1"/><xsl:text disable-output-escaping="yes">></xsl:text>--> + + <xsl:element name="{$sect.element}"> + <xsl:call-template name="id.attribute"/> + <title/> + <xsl:call-template name="make-section"> + <xsl:with-param name="current" select="$current"/> + <xsl:with-param name="prev" select="$prev +1"/> + </xsl:call-template> + <!--<xsl:text disable-output-escaping="yes"></sect</xsl:text><xsl:value-of select="$prev +1 "/><xsl:text disable-output-escaping="yes">></xsl:text>--> + + </xsl:element> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="sect.element"> + <xsl:text disable-output-escaping="yes">sect</xsl:text> + <xsl:value-of select="$current"/> + </xsl:variable> + <!--<xsl:text disable-output-escaping="yes"><sect</xsl:text><xsl:value-of select="$current"/><xsl:text disable-output-escaping="yes">></xsl:text>--> + + <xsl:element name="{$sect.element}"> + <xsl:call-template name="id.attribute"/> + <title> + <xsl:apply-templates/> + </title> + <xsl:apply-templates select="key('headchildren', generate-id())"/> + <xsl:apply-templates select="key('children', generate-id())"/> + <!--<xsl:text disable-output-escaping="yes"></sect</xsl:text><xsl:value-of select="$current"/><xsl:text disable-output-escaping="yes">></xsl:text>--> + + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template match="text:variable-set|text:variable-get"> + <xsl:choose> + <xsl:when test="contains(@text:name,'entitydecl')"> + <xsl:text disable-output-escaping="yes">&</xsl:text><xsl:value-of select="substring-after(@text:name,'entitydecl_')"/><xsl:text disable-output-escaping="yes">;</xsl:text> + </xsl:when> + </xsl:choose> + </xsl:template> + + + <xsl:template match="text:p[@text:style-name='XMLComment']"> + <xsl:comment> + <xsl:value-of select="."/> + </xsl:comment> + </xsl:template> + + <xsl:template match="text:section[@text:name = 'ArticleInfo']/text:p[not(@text:style-name='XMLComment')]"> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="text:p"> + <!--text:span text:style-name="XrefLabel" --> + <!--<xsl:if test="not( child::text:span[@text:style-name = 'XrefLabel'] )"> --> + + <xsl:element name="para"> + <xsl:if test="child::text:reference-mark-start"> + <xsl:value-of select="."/> + </xsl:if> + <xsl:apply-templates/> + </xsl:element> + <!-- </xsl:if> --> + + </xsl:template> + + + <xsl:template match="office:meta"> + <xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="text:ordered-list"> + <orderedlist> + <xsl:apply-templates/> + </orderedlist> + </xsl:template> + + <xsl:template match="meta:editing-cycles"/> + + <xsl:template match="meta:user-defined"/> + + <xsl:template match="meta:editing-duration"/> + + <xsl:template match="dc:language"/> + + <xsl:template match="dc:date"> + <!--<pubdate> + <xsl:value-of select="substring-before(.,'T')"/> + </pubdate>--> + </xsl:template> + + <xsl:template match="meta:creation-date"/> + + <xsl:template match="office:body"> + <xsl:apply-templates select="key('headchildren', generate-id())"/> + <xsl:apply-templates select="text:h[@text:level='1']"/> + <!--<xsl:apply-templates/>--> + </xsl:template> + + <xsl:template match="office:styles"> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="office:script"/> + + <xsl:template match="office:settings"/> + + <xsl:template match="office:font-decls"/> + + <xsl:template match="text:bookmark-start"> + <xsl:text disable-output-escaping="yes"><</xsl:text><xsl:value-of select="substring-before(@text:name,'_')"/><xsl:text disable-output-escaping="yes">></xsl:text><xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="text:bookmark-end"> + <xsl:text disable-output-escaping="yes"></</xsl:text><xsl:value-of select="substring-before(@text:name,'_')"/><xsl:text disable-output-escaping="yes">></xsl:text><xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="text:p[@text:style-name='Document Title']"> + <xsl:element name="title"> + <xsl:apply-templates /> + </xsl:element> + </xsl:template> + +<xsl:template match="text:p[@text:style-name='Document SubTitle']"> +</xsl:template> + + <xsl:template match="text:p[@text:style-name='Document SubTitle']"/> + + <xsl:template match="text:p[@text:style-name='Section Title']"> + <title> + <xsl:apply-templates/> + </title> + </xsl:template> + + <xsl:template match="text:p[@text:style-name='Appendix Title']"> + <title> + <xsl:apply-templates/> + </title> + </xsl:template> + + + <xsl:template match="text:p[@text:style-name='VarList Item']"> + <xsl:if test="not(preceding-sibling::text:p[@text:style-name='VarList Item'])"> + <xsl:text disable-output-escaping="yes"><listitem></xsl:text> + </xsl:if> + <para> + <xsl:apply-templates/> + </para> + <xsl:if test="not(following-sibling::text:p[@text:style-name='VarList Item'])"> + <xsl:text disable-output-escaping="yes"></listitem></xsl:text> + </xsl:if> + </xsl:template> + + + <xsl:template match="text:p[@text:style-name='VarList Term']"> + <term> + <xsl:apply-templates/> + </term> + </xsl:template> + + + <xsl:template match="text:p[@text:style-name='Section1 Title']"> + <title> + <xsl:apply-templates/> + </title> + </xsl:template> + + + <xsl:template match="text:p[@text:style-name='Section2 Title']"> + <title> + <xsl:apply-templates/> + </title> + </xsl:template> + + + <xsl:template match="text:p[@text:style-name='Section3 Title']"> + <title> + <xsl:apply-templates/> + </title> + </xsl:template> + + + <xsl:template match="text:footnote-citation"/> + + + <xsl:template match="text:p[@text:style-name='Mediaobject']"> + <mediaobject> + <xsl:apply-templates/> + </mediaobject> + </xsl:template> + + + <xsl:template match="office:annotation/text:p"> + <note> + <remark> + <xsl:apply-templates/> + </remark> + </note> + </xsl:template> + <!--<xsl:template match="meta:initial-creator"> + <author> + <xsl:apply-templates /> + </author> + </xsl:template>--> + + <xsl:template match="table:table"> + <xsl:choose> + <xsl:when test="following-sibling::text:p[@text:style-name='Table']"> + <table frame="all"> + <xsl:attribute name="id"> + <xsl:value-of select="@table:name"/> + </xsl:attribute> + <title> + <xsl:value-of select="following-sibling::text:p[@text:style-name='Table']"/> + </title> + <xsl:call-template name="generictable"/> + </table> + </xsl:when> + <xsl:otherwise> + <informaltable frame="all"> + <xsl:call-template name="generictable"/> + </informaltable> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template name="generictable"> + <xsl:variable name="cells" select="count(descendant::table:table-cell)"/> + <xsl:variable name="rows"> + <xsl:value-of select="count(descendant::table:table-row) "/> + </xsl:variable> + <xsl:variable name="cols"> + <xsl:value-of select="$cells div $rows"/> + </xsl:variable> + <xsl:variable name="numcols"> + <xsl:choose> + <xsl:when test="child::table:table-column/@table:number-columns-repeated"> + <xsl:value-of select="number(table:table-column/@table:number-columns-repeated+1)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$cols"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:element name="tgroup"> + <xsl:attribute name="cols"> + <xsl:value-of select="$numcols"/> + </xsl:attribute> + <xsl:call-template name="colspec"> + <xsl:with-param name="left" select="1"/> + </xsl:call-template> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template name="colspec"> + <xsl:param name="left"/> + <xsl:if test="number($left < ( table:table-column/@table:number-columns-repeated +2) )"> + <xsl:element name="colspec"> + <xsl:attribute name="colnum"> + <xsl:value-of select="$left"/> + </xsl:attribute> + <xsl:attribute name="colname">c + <xsl:value-of select="$left"/> + </xsl:attribute> + </xsl:element> + <xsl:call-template name="colspec"> + <xsl:with-param name="left" select="$left+1"/> + </xsl:call-template> + </xsl:if> + </xsl:template> + + + <xsl:template match="table:table-column"> + <xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="table:table-header-rows"> + <thead> + <xsl:apply-templates/> + </thead> + </xsl:template> + + + <xsl:template match="table:table-header-rows/table:table-row"> + <row> + <xsl:apply-templates/> + </row> + </xsl:template> + + + <xsl:template match="table:table/table:table-row"> + <xsl:if test="not(preceding-sibling::table:table-row)"> + <xsl:text disable-output-escaping="yes"><tbody></xsl:text> + </xsl:if> + <row> + <xsl:apply-templates/> + </row> + <xsl:if test="not(following-sibling::table:table-row)"> + <xsl:text disable-output-escaping="yes"></tbody></xsl:text> + </xsl:if> + </xsl:template> + + + <xsl:template match="table:table-cell"> + <xsl:element name="entry"> + <xsl:if test="@table:number-columns-spanned >'1'"> + <xsl:attribute name="namest"> + <xsl:value-of select="concat('c',count(preceding-sibling::table:table-cell[not(@table:number-columns-spanned)]) +sum(preceding-sibling::table:table-cell/@table:number-columns-spanned)+1)"/> + </xsl:attribute> + <xsl:attribute name="nameend"> + <xsl:value-of select="concat('c',count(preceding-sibling::table:table-cell[not(@table:number-columns-spanned)]) +sum(preceding-sibling::table:table-cell/@table:number-columns-spanned)+ @table:number-columns-spanned)"/> + </xsl:attribute> + </xsl:if> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="text:p"> + <xsl:choose> + <xsl:when test="@text:style-name='Table'"/> + <xsl:otherwise> + <xsl:if test="not( child::text:span[@text:style-name = 'XrefLabel'] )"> + <para> + <xsl:call-template name="id.attribute"/> + <xsl:apply-templates/> + </para> + </xsl:if> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template match="text:unordered-list"> + <xsl:choose> + <xsl:when test="@text:style-name='Var List'"> + <variablelist> + <xsl:apply-templates/> + </variablelist> + </xsl:when> + <xsl:when test="@text:style-name='UnOrdered List'"> + <variablelist> + <xsl:apply-templates/> + </variablelist> + </xsl:when> + <xsl:otherwise> + <itemizedlist> + <title/> + <xsl:apply-templates/> + </itemizedlist> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template match="text:list-item"> + <xsl:if test="parent::text:unordered-list/@text:style-name='Var List'"> + <varlistentry> + <xsl:for-each select="text:p[@text:style-name='VarList Term']"> + <xsl:apply-templates select="."/> + </xsl:for-each> + </varlistentry> + </xsl:if> + <xsl:if test="not(parent::text:unordered-list/@text:style-name='Var List')"> + <listitem> + <xsl:apply-templates/> + </listitem> + </xsl:if> + </xsl:template> + + + <xsl:template match="dc:title"/> + + + <xsl:template match="dc:description"> + <abstract> + <para> + <xsl:apply-templates/> + </para> + </abstract> + </xsl:template> + + + <xsl:template match="dc:subject"/> + + <xsl:template match="meta:generator"/> + + <xsl:template match="draw:plugin"> + <xsl:element name="audioobject"> + <xsl:attribute name="fileref"> + <xsl:value-of select="@xlink:href"/> + </xsl:attribute> + <xsl:attribute name="width"/> + </xsl:element> + </xsl:template> + + + <xsl:template match="text:footnote"> + <footnote> + <xsl:apply-templates/> + </footnote> + </xsl:template> + + + <xsl:template match="text:footnote-body"> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="draw:text-box"/> + + <xsl:template match="draw:image"> + <xsl:choose> + <xsl:when test="parent::text:p[@text:style-name='Mediaobject']"> + <xsl:element name="imageobject"> + <xsl:element name="imagedata"> + <xsl:attribute name="fileref"> + <xsl:value-of select="@xlink:href"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="caption"> + <xsl:value-of select="."/> + </xsl:element> + </xsl:element> + </xsl:when> + <xsl:otherwise> + <xsl:element name="inlinegraphic"> + <xsl:attribute name="fileref"> + <xsl:value-of select="@xlink:href"/> + </xsl:attribute> + <xsl:attribute name="width"/> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template match="text:span"> + <xsl:choose> + <xsl:when test="./@text:style-name='GuiMenu'"> + <xsl:element name="guimenu"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="./@text:style-name='GuiSubMenu'"> + <xsl:element name="guisubmenu"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='GuiMenuItem'"> + <xsl:element name="guimenuitem"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='GuiButton'"> + <xsl:element name="guibutton"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='GuiButton'"> + <xsl:element name="guibutton"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='GuiLabel'"> + <xsl:element name="guilabel"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='Emphasis'"> + <xsl:element name="emphasis"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> +<!-- Change Made By Kevin Fowlks (fowlks@msu.edu) June 4th, 2003 --> + <xsl:when test="@text:style-name='Emphasis Bold'"> + <xsl:element name="emphasis"> + <xsl:attribute name = "role" > + <xsl:text>bold</xsl:text> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> +<!-- Change Made By Kevin Fowlks (fowlks@msu.edu) June 16th, 2003 --> + <xsl:when test="@text:style-name='Citation'"> + <xsl:element name="quote"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='FileName'"> + <xsl:element name="filename"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='Application'"> + <xsl:element name="application"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='Command'"> + <command> + <xsl:apply-templates/> + </command> + </xsl:when> + <xsl:when test="@text:style-name='SubScript'"> + <subscript> + <xsl:apply-templates/> + </subscript> + </xsl:when> + <xsl:when test="@text:style-name='SuperScript'"> + <superscript> + <xsl:apply-templates/> + </superscript> + </xsl:when> + <xsl:when test="@text:style-name='SystemItem'"> + <systemitem> + <xsl:apply-templates/> + </systemitem> + </xsl:when> + <xsl:when test="@text:style-name='ComputerOutput'"> + <computeroutput> + <xsl:apply-templates/> + </computeroutput> + </xsl:when> + <xsl:when test="@text:style-name='Highlight'"> + <highlight> + <xsl:apply-templates/> + </highlight> + </xsl:when> + <xsl:when test="@text:style-name='KeyCap'"> + <keycap> + <xsl:apply-templates/> + </keycap> + </xsl:when> + <xsl:when test="@text:style-name='KeySym'"> + <xsl:element name="keysym"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='KeyCombo'"> + <keycombo> + <xsl:apply-templates/> + </keycombo> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template match="text:a"> + <xsl:choose> + <xsl:when test="contains(@xlink:href,'://')"> + <xsl:element name="ulink"> + <xsl:attribute name="url"> + <xsl:value-of select="@xlink:href"/> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="not(contains(@xlink:href,'#'))"> + <xsl:element name="olink"> + <xsl:attribute name="targetdocent"> + <xsl:value-of select="@xlink:href"/> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="linkvar" select="substring-after(@xlink:href,'#')"/> + <xsl:element name="link"> + <xsl:attribute name="linkend"> + <xsl:value-of select="substring-before($linkvar,'%')"/> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template match="text:line-break"> + <xsl:text disable-output-escaping="yes"/> + </xsl:template> + + + <xsl:template match="text:tab-stop"> + <xsl:text disable-output-escaping="yes"/> + </xsl:template> + <!-- @endterm not retained due to problems with OOo method of displaying text in the reference-ref --> + + <xsl:template match="text:reference-ref"> + <xsl:element name="xref"> + <xsl:attribute name="linkend"> + <xsl:value-of select="@text:ref-name"/> + </xsl:attribute> + </xsl:element> + </xsl:template> + + + <xsl:template name="id.attribute"> + <xsl:if test="child::text:reference-mark-start"> + <xsl:attribute name="id"> + <xsl:value-of select="child::text:reference-mark-start/@text:name"/> + </xsl:attribute> + </xsl:if> + <!-- Constraints imposed by OOo method of displaying reference-ref text means that xreflabel and endterm are lost --> + <!--<xsl:if test="child::text:p/text:span[@text:style-name = 'XrefLabel']"> + <xsl:attribute name="xreflabel"> + <xsl:value-of select="text:p/text:span"/> + </xsl:attribute> + </xsl:if> --> + + </xsl:template> + <!-- + <text:h text:level="1">Part One Title + <text:reference-mark-start text:name="part"/> + <text:p text:style-name="Text body"> + <text:span text:style-name="XrefLabel">xreflabel_part</text:span> + </text:p> + <text:reference-mark-end text:name="part"/> + </text:h> +--> + <!--<xsl:template match="text:p/text:span[@text:style-name = 'XrefLabel']"/>--> + + <xsl:template match="text:reference-mark-start"/> + + <xsl:template match="text:reference-mark-end"/> + + <xsl:template match="comment"> + <xsl:comment> + <xsl:value-of select="."/> + </xsl:comment> + </xsl:template> + + + <xsl:template match="text:alphabetical-index-mark-start"> + <xsl:element name="indexterm"> + <xsl:attribute name="class"> + <xsl:text disable-output-escaping="yes">startofrange</xsl:text> + </xsl:attribute> + <xsl:attribute name="id"> + <xsl:value-of select="@text:id"/> + </xsl:attribute> + <!--<xsl:if test="@text:key1">--> + + <xsl:element name="primary"> + <xsl:value-of select="@text:key1"/> + </xsl:element> + <!--</xsl:if>--> + + <xsl:if test="@text:key2"> + <xsl:element name="secondary"> + <xsl:value-of select="@text:key2"/> + </xsl:element> + </xsl:if> + </xsl:element> + </xsl:template> + + + <xsl:template match="text:alphabetical-index-mark-end"> + <xsl:element name="indexterm"> + <xsl:attribute name="startref"> + <xsl:value-of select="@text:id"/> + </xsl:attribute> + <xsl:attribute name="class"> + <xsl:text disable-output-escaping="yes">endofrange</xsl:text> + </xsl:attribute> + </xsl:element> + </xsl:template> + + + <xsl:template match="text:alphabetical-index"> + <xsl:element name="index"> + <xsl:element name="title"> + <xsl:value-of select="text:index-body/text:index-title/text:p"/> + </xsl:element> + <xsl:apply-templates select="text:index-body"/> + </xsl:element> + </xsl:template> + + + <xsl:template match="text:index-body"> + <xsl:for-each select="text:p[@text:style-name = 'Index 1']"> + <xsl:element name="indexentry"> + <xsl:element name="primaryie"> + <xsl:value-of select="."/> + </xsl:element> + <xsl:if test="key('secondary_children', generate-id())"> + <xsl:element name="secondaryie"> + <xsl:value-of select="key('secondary_children', generate-id())"/> + </xsl:element> + </xsl:if> + </xsl:element> + </xsl:for-each> + </xsl:template> + +</xsl:stylesheet> + diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/sofftodocbookheadings_chapter.xsl b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/sofftodocbookheadings_chapter.xsl new file mode 100644 index 000000000000..efb03f0a741c --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/docbook/sofftodocbookheadings_chapter.xsl @@ -0,0 +1,858 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + + Copyright 2000, 2010 Oracle and/or its affiliates. + + OpenOffice.org - a multi-platform office productivity suite + + This file is part of OpenOffice.org. + + OpenOffice.org is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + OpenOffice.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details + (a copy is included in the LICENSE file that accompanied this code). + + You should have received a copy of the GNU Lesser General Public License + version 3 along with OpenOffice.org. If not, see + <http://www.openoffice.org/license.html> + for a copy of the LGPLv3 License. + +--> + +<xsl:stylesheet version="1.0" xmlns:style="http://openoffice.org/2000/style" xmlns:text="http://openoffice.org/2000/text" xmlns:office="http://openoffice.org/2000/office" xmlns:table="http://openoffice.org/2000/table" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="http://openoffice.org/2000/meta" xmlns:number="http://openoffice.org/2000/datastyle" xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart" xmlns:dr3d="http://openoffice.org/2000/dr3d" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="http://openoffice.org/2000/form" xmlns:script="http://openoffice.org/2000/script" xmlns:config="http://openoffice.org/2001/config" office:class="text" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="office meta table number dc fo xlink chart math script xsl draw svg dr3d form config text style"> + + <xsl:key name='headchildren' match="text:p | text:alphabetical-index | table:table | text:span | text:ordered-list | office:annotation | text:unordered-list | text:footnote | text:a | text:list-item | draw:plugin | draw:text-box | text:footnote-body | text:section" + use="generate-id((..|preceding-sibling::text:h[@text:level='1']|preceding-sibling::text:h[@text:level='2']|preceding-sibling::text:h[@text:level='3']|preceding-sibling::text:h[@text:level='4']|preceding-sibling::text:h[@text:level='5'])[last()])"/> + + <xsl:key name="children" match="text:h[@text:level='2']" + use="generate-id(preceding-sibling::text:h[@text:level='1'][1])"/> + + <xsl:key name="children" match="text:h[@text:level='3']" + use="generate-id(preceding-sibling::text:h[@text:level='2' or @text:level='1'][1])"/> + + <xsl:key name="children" match="text:h[@text:level='4']" + use="generate-id(preceding-sibling::text:h[@text:level='3' or @text:level='2' or @text:level='1'][1])"/> + + <xsl:key name="children" match="text:h[@text:level='5']" + use="generate-id(preceding-sibling::text:h[@text:level='4' or @text:level='3' or @text:level='2' or @text:level='1'][1])"/> + + <xsl:key name="secondary_children" match="text:p[@text:style-name = 'Index 2']" + use="generate-id(preceding-sibling::text:p[@text:style-name = 'Index 1'][1])"/> + +<!-- --> + <xsl:template match="/office:document"> + <xsl:text disable-output-escaping="yes"><!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [ + </xsl:text> + <xsl:for-each select="descendant::text:variable-decl"> + <xsl:variable name="name"><xsl:value-of select="@text:name"/></xsl:variable> + <xsl:if test="contains(@text:name,'entitydecl')"> + <xsl:text disable-output-escaping="yes"><!ENTITY </xsl:text><xsl:value-of select="substring-after(@text:name,'entitydecl_')"/><xsl:text> "</xsl:text><xsl:value-of select="/descendant::text:variable-set[@text:name= $name][1]"/><xsl:text disable-output-escaping="yes">"></xsl:text> + </xsl:if> + </xsl:for-each> + + <xsl:text disable-output-escaping="yes">]></xsl:text> + <chapter> + <xsl:attribute name="lang"> + <xsl:value-of select="/office:document/office:meta/dc:language"/> + </xsl:attribute> + <xsl:apply-templates/> + </chapter> + </xsl:template> + + + <xsl:template match="text:section"> + <xsl:choose> + <xsl:when test="@text:name='ChapterInfo'"> + <chapterinfo> + <xsl:apply-templates/> + </chapterinfo> + </xsl:when> + <xsl:when test="@text:name='Abstract'"> + <abstract> + <xsl:apply-templates/> + </abstract> + </xsl:when> + <xsl:when test="@text:name='Appendix'"> + <appendix> + <xsl:apply-templates/> + </appendix> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="sectvar"><xsl:text>sect</xsl:text><xsl:value-of select="count(ancestor::text:section)+1"/></xsl:variable> + <xsl:variable name="idvar"><xsl:text> id="</xsl:text><xsl:value-of select="@text:name"/><xsl:text>"</xsl:text></xsl:variable> + <xsl:text disable-output-escaping="yes"><</xsl:text><xsl:value-of select="$sectvar"/><xsl:value-of select="$idvar"/><xsl:text disable-output-escaping="yes">></xsl:text> + <xsl:apply-templates/> + <xsl:text disable-output-escaping="yes"></</xsl:text><xsl:value-of select="$sectvar"/><xsl:text disable-output-escaping="yes">></xsl:text> + </xsl:otherwise> +</xsl:choose> + + </xsl:template> + + <xsl:template match="text:h[@text:level='1']"> + <xsl:choose> + <xsl:when test=".='Abstract'"> + <abstract> + <xsl:apply-templates select="key('headchildren', generate-id())"/> + <xsl:apply-templates select="key('children', generate-id())"/> + </abstract> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="make-section"> + <xsl:with-param name="current" select="@text:level"/> + <xsl:with-param name="prev" select="1"/> + </xsl:call-template> + <!--<sect1> + <title> + <xsl:apply-templates/> + </title> + <xsl:apply-templates select="key('headchildren', generate-id())"/> + <xsl:apply-templates select="key('children', generate-id())"/> + </sect1>--> + + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template match="text:h[@text:level='2'] | text:h[@text:level='3']| text:h[@text:level='4'] | text:h[@text:level='5']"> + <xsl:variable name="level" select="@text:level"/> + <xsl:call-template name="make-section"> + <xsl:with-param name="current" select="$level"/> + <xsl:with-param name="prev" select="preceding-sibling::text:h[@text:level < $level][1]/@text:level "/> + </xsl:call-template> + </xsl:template> + + + <xsl:template name="make-section"> + <xsl:param name="current"/> + <xsl:param name="prev"/> + <xsl:choose> + <xsl:when test="$current > $prev+1"> + <xsl:variable name="sect.element"> + <xsl:text disable-output-escaping="yes">sect</xsl:text> + <xsl:value-of select="$prev +1"/> + </xsl:variable> + <!--<xsl:text disable-output-escaping="yes"><sect</xsl:text><xsl:value-of select="$prev +1"/><xsl:text disable-output-escaping="yes">></xsl:text>--> + + <xsl:element name="{$sect.element}"> + <xsl:call-template name="id.attribute"/> + <title/> + <xsl:call-template name="make-section"> + <xsl:with-param name="current" select="$current"/> + <xsl:with-param name="prev" select="$prev +1"/> + </xsl:call-template> + <!--<xsl:text disable-output-escaping="yes"></sect</xsl:text><xsl:value-of select="$prev +1 "/><xsl:text disable-output-escaping="yes">></xsl:text>--> + + </xsl:element> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="sect.element"> + <xsl:text disable-output-escaping="yes">sect</xsl:text> + <xsl:value-of select="$current"/> + </xsl:variable> + <!--<xsl:text disable-output-escaping="yes"><sect</xsl:text><xsl:value-of select="$current"/><xsl:text disable-output-escaping="yes">></xsl:text>--> + + <xsl:element name="{$sect.element}"> + <xsl:call-template name="id.attribute"/> + <title> + <xsl:apply-templates/> + </title> + <xsl:apply-templates select="key('headchildren', generate-id())"/> + <xsl:apply-templates select="key('children', generate-id())"/> + <!--<xsl:text disable-output-escaping="yes"></sect</xsl:text><xsl:value-of select="$current"/><xsl:text disable-output-escaping="yes">></xsl:text>--> + + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template match="text:variable-set"> + <xsl:choose> + <xsl:when test="contains(@text:name,'entitydecl')"> + <xsl:text disable-output-escaping="yes">&</xsl:text><xsl:value-of select="substring-after(@text:name,'entitydecl_')"/><xsl:text disable-output-escaping="yes">;</xsl:text> + </xsl:when> + </xsl:choose> + </xsl:template> + + <xsl:template match="text:variable-get"> + <xsl:choose> + <xsl:when test="contains(@text:name,'entitydecl')"> + <xsl:text disable-output-escaping="yes">&</xsl:text><xsl:value-of select="substring-after(@text:name,'entitydecl_')"/><xsl:text disable-output-escaping="yes">;</xsl:text> + </xsl:when> + </xsl:choose> + </xsl:template> + + + + + <xsl:template match="text:p[@text:style-name='XMLComment']"> + <xsl:comment> + <xsl:value-of select="."/> + </xsl:comment> + </xsl:template> + + <xsl:template match="text:section[@text:name = 'ChapterInfo']/text:p[not(@text:style-name='XMLComment')]"> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="text:p"> + <!--text:span text:style-name="XrefLabel" --> + <!--<xsl:if test="not( child::text:span[@text:style-name = 'XrefLabel'] )"> --> + + <xsl:element name="para"> + <xsl:if test="child::text:reference-mark-start"> + <xsl:value-of select="."/> + </xsl:if> + <xsl:apply-templates/> + </xsl:element> + <!-- </xsl:if> --> + + </xsl:template> + + + <xsl:template match="office:meta"> + <xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="text:ordered-list"> + <orderedlist> + <xsl:apply-templates/> + </orderedlist> + </xsl:template> + + <xsl:template match="meta:editing-cycles"/> + + <xsl:template match="meta:user-defined"/> + + <xsl:template match="meta:editing-duration"/> + + <xsl:template match="dc:language"/> + + <xsl:template match="dc:date"> + <!--<pubdate> + <xsl:value-of select="substring-before(.,'T')"/> + </pubdate>--> + </xsl:template> + + <xsl:template match="meta:creation-date"/> + + <xsl:template match="office:body"> + <xsl:apply-templates select="key('headchildren', generate-id())"/> + <xsl:apply-templates select="text:h[@text:level='1']"/> + <!--<xsl:apply-templates/>--> + </xsl:template> + + <xsl:template match="office:styles"> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="office:script"/> + + <xsl:template match="office:settings"/> + + <xsl:template match="office:font-decls"/> + + <xsl:template match="text:bookmark-start"> + <xsl:text disable-output-escaping="yes"><</xsl:text><xsl:value-of select="substring-before(@text:name,'_')"/><xsl:text disable-output-escaping="yes">></xsl:text><xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="text:bookmark-end"> + <xsl:text disable-output-escaping="yes"></</xsl:text><xsl:value-of select="substring-before(@text:name,'_')"/><xsl:text disable-output-escaping="yes">></xsl:text><xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="text:p[@text:style-name='Document Title']"> + <xsl:element name="title"> + <xsl:apply-templates /> + </xsl:element> + </xsl:template> + +<xsl:template match="text:p[@text:style-name='Document SubTitle']"> +</xsl:template> + + <xsl:template match="text:p[@text:style-name='Document SubTitle']"/> + + <xsl:template match="text:p[@text:style-name='Section Title']"> + <title> + <xsl:apply-templates/> + </title> + </xsl:template> + + <xsl:template match="text:p[@text:style-name='Appendix Title']"> + <title> + <xsl:apply-templates/> + </title> + </xsl:template> + + + <xsl:template match="text:p[@text:style-name='VarList Item']"> + <xsl:if test="not(preceding-sibling::text:p[@text:style-name='VarList Item'])"> + <xsl:text disable-output-escaping="yes"><listitem></xsl:text> + </xsl:if> + <para> + <xsl:apply-templates/> + </para> + <xsl:if test="not(following-sibling::text:p[@text:style-name='VarList Item'])"> + <xsl:text disable-output-escaping="yes"></listitem></xsl:text> + </xsl:if> + </xsl:template> + + + <xsl:template match="text:p[@text:style-name='VarList Term']"> + <term> + <xsl:apply-templates/> + </term> + </xsl:template> + + + <xsl:template match="text:p[@text:style-name='Section1 Title']"> + <title> + <xsl:apply-templates/> + </title> + </xsl:template> + + + <xsl:template match="text:p[@text:style-name='Section2 Title']"> + <title> + <xsl:apply-templates/> + </title> + </xsl:template> + + + <xsl:template match="text:p[@text:style-name='Section3 Title']"> + <title> + <xsl:apply-templates/> + </title> + </xsl:template> + + + <xsl:template match="text:footnote-citation"/> + + + <xsl:template match="text:p[@text:style-name='Mediaobject']"> + <mediaobject> + <xsl:apply-templates/> + </mediaobject> + </xsl:template> + + + <xsl:template match="office:annotation/text:p"> + <note> + <remark> + <xsl:apply-templates/> + </remark> + </note> + </xsl:template> + <!--<xsl:template match="meta:initial-creator"> + <author> + <xsl:apply-templates /> + </author> + </xsl:template>--> + + <xsl:template match="table:table"> + <xsl:choose> + <xsl:when test="following-sibling::text:p[@text:style-name='Table']"> + <table frame="all"> + <xsl:attribute name="id"> + <xsl:value-of select="@table:name"/> + </xsl:attribute> + <title> + <xsl:value-of select="following-sibling::text:p[@text:style-name='Table']"/> + </title> + <xsl:call-template name="generictable"/> + </table> + </xsl:when> + <xsl:otherwise> + <informaltable frame="all"> + <xsl:call-template name="generictable"/> + </informaltable> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template name="generictable"> + <xsl:variable name="cells" select="count(descendant::table:table-cell)"/> + <xsl:variable name="rows"> + <xsl:value-of select="count(descendant::table:table-row) "/> + </xsl:variable> + <xsl:variable name="cols"> + <xsl:value-of select="$cells div $rows"/> + </xsl:variable> + <xsl:variable name="numcols"> + <xsl:choose> + <xsl:when test="child::table:table-column/@table:number-columns-repeated"> + <xsl:value-of select="number(table:table-column/@table:number-columns-repeated+1)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$cols"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:element name="tgroup"> + <xsl:attribute name="cols"> + <xsl:value-of select="$numcols"/> + </xsl:attribute> + <xsl:call-template name="colspec"> + <xsl:with-param name="left" select="1"/> + </xsl:call-template> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template name="colspec"> + <xsl:param name="left"/> + <xsl:if test="number($left < ( table:table-column/@table:number-columns-repeated +2) )"> + <xsl:element name="colspec"> + <xsl:attribute name="colnum"> + <xsl:value-of select="$left"/> + </xsl:attribute> + <xsl:attribute name="colname">c + <xsl:value-of select="$left"/> + </xsl:attribute> + </xsl:element> + <xsl:call-template name="colspec"> + <xsl:with-param name="left" select="$left+1"/> + </xsl:call-template> + </xsl:if> + </xsl:template> + + + <xsl:template match="table:table-column"> + <xsl:apply-templates/> + </xsl:template> + + + <xsl:template match="table:table-header-rows"> + <thead> + <xsl:apply-templates/> + </thead> + </xsl:template> + + + <xsl:template match="table:table-header-rows/table:table-row"> + <row> + <xsl:apply-templates/> + </row> + </xsl:template> + + + <xsl:template match="table:table/table:table-row"> + <xsl:if test="not(preceding-sibling::table:table-row)"> + <xsl:text disable-output-escaping="yes"><tbody></xsl:text> + </xsl:if> + <row> + <xsl:apply-templates/> + </row> + <xsl:if test="not(following-sibling::table:table-row)"> + <xsl:text disable-output-escaping="yes"></tbody></xsl:text> + </xsl:if> + </xsl:template> + + + <xsl:template match="table:table-cell"> + <xsl:element name="entry"> + <xsl:if test="@table:number-columns-spanned >'1'"> + <xsl:attribute name="namest"> + <xsl:value-of select="concat('c',count(preceding-sibling::table:table-cell[not(@table:number-columns-spanned)]) +sum(preceding-sibling::table:table-cell/@table:number-columns-spanned)+1)"/> + </xsl:attribute> + <xsl:attribute name="nameend"> + <xsl:value-of select="concat('c',count(preceding-sibling::table:table-cell[not(@table:number-columns-spanned)]) +sum(preceding-sibling::table:table-cell/@table:number-columns-spanned)+ @table:number-columns-spanned)"/> + </xsl:attribute> + </xsl:if> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + <xsl:template match="text:p"> + <xsl:choose> + <xsl:when test="@text:style-name='Table'"/> + <xsl:otherwise> + <xsl:if test="not( child::text:span[@text:style-name = 'XrefLabel'] )"> + <para> + <xsl:call-template name="id.attribute"/> + <xsl:apply-templates/> + </para> + </xsl:if> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template match="text:unordered-list"> + <xsl:choose> + <xsl:when test="@text:style-name='Var List'"> + <variablelist> + <xsl:apply-templates/> + </variablelist> + </xsl:when> + <xsl:when test="@text:style-name='UnOrdered List'"> + <variablelist> + <xsl:apply-templates/> + </variablelist> + </xsl:when> + <xsl:otherwise> + <itemizedlist> + <title/> + <xsl:apply-templates/> + </itemizedlist> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template match="text:list-item"> + <xsl:if test="parent::text:unordered-list/@text:style-name='Var List'"> + <varlistentry> + <xsl:for-each select="text:p[@text:style-name='VarList Term']"> + <xsl:apply-templates select="."/> + </xsl:for-each> + </varlistentry> + </xsl:if> + <xsl:if test="not(parent::text:unordered-list/@text:style-name='Var List')"> + <listitem> + <xsl:apply-templates/> + </listitem> + </xsl:if> + </xsl:template> + + + <xsl:template match="dc:title"/> + + + <xsl:template match="dc:description"> + <abstract> + <para> + <xsl:apply-templates/> + </para> + </abstract> + </xsl:template> + + + <xsl:template match="dc:subject"/> + + <xsl:template match="meta:generator"/> + + <xsl:template match="draw:plugin"> + <xsl:element name="audioobject"> + <xsl:attribute name="fileref"> + <xsl:value-of select="@xlink:href"/> + </xsl:attribute> + <xsl:attribute name="width"/> + </xsl:element> + </xsl:template> + + + <xsl:template match="text:footnote"> + <footnote> + <xsl:apply-templates/> + </footnote> + </xsl:template> + + + <xsl:template match="text:footnote-body"> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="draw:text-box"/> + + <xsl:template match="draw:image"> + <xsl:choose> + <xsl:when test="parent::text:p[@text:style-name='Mediaobject']"> + <xsl:element name="imageobject"> + <xsl:element name="imagedata"> + <xsl:attribute name="fileref"> + <xsl:value-of select="@xlink:href"/> + </xsl:attribute> + </xsl:element> + <xsl:element name="caption"> + <xsl:value-of select="."/> + </xsl:element> + </xsl:element> + </xsl:when> + <xsl:otherwise> + <xsl:element name="inlinegraphic"> + <xsl:attribute name="fileref"> + <xsl:value-of select="@xlink:href"/> + </xsl:attribute> + <xsl:attribute name="width"/> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template match="text:span"> + <xsl:choose> + <xsl:when test="./@text:style-name='GuiMenu'"> + <xsl:element name="guimenu"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="./@text:style-name='GuiSubMenu'"> + <xsl:element name="guisubmenu"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='GuiMenuItem'"> + <xsl:element name="guimenuitem"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='GuiButton'"> + <xsl:element name="guibutton"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='GuiButton'"> + <xsl:element name="guibutton"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='GuiLabel'"> + <xsl:element name="guilabel"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='Emphasis'"> + <xsl:element name="emphasis"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> +<!-- Change Made By Kevin Fowlks (fowlks@msu.edu) June 4th, 2003 --> + <xsl:when test="@text:style-name='Emphasis Bold'"> + <xsl:element name="emphasis"> + <xsl:attribute name = "role" > + <xsl:text >bold</xsl:text> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> +<!-- Change Made By Kevin Fowlks (fowlks@msu.edu) June 16th, 2003 --> + <xsl:when test="@text:style-name='Citation'"> + <xsl:element name="quote"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='FileName'"> + <xsl:element name="filename"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='Application'"> + <xsl:element name="application"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='Command'"> + <command> + <xsl:apply-templates/> + </command> + </xsl:when> + <xsl:when test="@text:style-name='SubScript'"> + <subscript> + <xsl:apply-templates/> + </subscript> + </xsl:when> + <xsl:when test="@text:style-name='SuperScript'"> + <superscript> + <xsl:apply-templates/> + </superscript> + </xsl:when> + <xsl:when test="@text:style-name='SystemItem'"> + <systemitem> + <xsl:apply-templates/> + </systemitem> + </xsl:when> + <xsl:when test="@text:style-name='ComputerOutput'"> + <computeroutput> + <xsl:apply-templates/> + </computeroutput> + </xsl:when> + <xsl:when test="@text:style-name='Highlight'"> + <highlight> + <xsl:apply-templates/> + </highlight> + </xsl:when> + <xsl:when test="@text:style-name='KeyCap'"> + <keycap> + <xsl:apply-templates/> + </keycap> + </xsl:when> + <xsl:when test="@text:style-name='KeySym'"> + <xsl:element name="keysym"> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="@text:style-name='KeyCombo'"> + <keycombo> + <xsl:apply-templates/> + </keycombo> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template match="text:a"> + <xsl:choose> + <xsl:when test="contains(@xlink:href,'://')"> + <xsl:element name="ulink"> + <xsl:attribute name="url"> + <xsl:value-of select="@xlink:href"/> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:when test="not(contains(@xlink:href,'#'))"> + <xsl:element name="olink"> + <xsl:attribute name="targetdocent"> + <xsl:value-of select="@xlink:href"/> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="linkvar" select="substring-after(@xlink:href,'#')"/> + <xsl:element name="link"> + <xsl:attribute name="linkend"> + <xsl:value-of select="substring-before($linkvar,'%')"/> + </xsl:attribute> + <xsl:apply-templates/> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + <xsl:template match="text:line-break"> + <xsl:text disable-output-escaping="yes"/> + </xsl:template> + + + <xsl:template match="text:tab-stop"> + <xsl:text disable-output-escaping="yes"/> + </xsl:template> + <!-- @endterm not retained due to problems with OOo method of displaying text in the reference-ref --> + + <xsl:template match="text:reference-ref"> + <xsl:element name="xref"> + <xsl:attribute name="linkend"> + <xsl:value-of select="@text:ref-name"/> + </xsl:attribute> + </xsl:element> + </xsl:template> + + + <xsl:template name="id.attribute"> + <xsl:if test="child::text:reference-mark-start"> + <xsl:attribute name="id"> + <xsl:value-of select="child::text:reference-mark-start/@text:name"/> + </xsl:attribute> + </xsl:if> + <!-- Constraints imposed by OOo method of displaying reference-ref text means that xreflabel and endterm are lost --> + <!--<xsl:if test="child::text:p/text:span[@text:style-name = 'XrefLabel']"> + <xsl:attribute name="xreflabel"> + <xsl:value-of select="text:p/text:span"/> + </xsl:attribute> + </xsl:if> --> + + </xsl:template> + <!-- + <text:h text:level="1">Part One Title + <text:reference-mark-start text:name="part"/> + <text:p text:style-name="Text body"> + <text:span text:style-name="XrefLabel">xreflabel_part</text:span> + </text:p> + <text:reference-mark-end text:name="part"/> + </text:h> +--> + <!--<xsl:template match="text:p/text:span[@text:style-name = 'XrefLabel']"/>--> + + <xsl:template match="text:reference-mark-start"/> + + <xsl:template match="text:reference-mark-end"/> + + <xsl:template match="comment"> + <xsl:comment> + <xsl:value-of select="."/> + </xsl:comment> + </xsl:template> + + + <xsl:template match="text:alphabetical-index-mark-start"> + <xsl:element name="indexterm"> + <xsl:attribute name="class"> + <xsl:text disable-output-escaping="yes">startofrange</xsl:text> + </xsl:attribute> + <xsl:attribute name="id"> + <xsl:value-of select="@text:id"/> + </xsl:attribute> + <!--<xsl:if test="@text:key1">--> + + <xsl:element name="primary"> + <xsl:value-of select="@text:key1"/> + </xsl:element> + <!--</xsl:if>--> + + <xsl:if test="@text:key2"> + <xsl:element name="secondary"> + <xsl:value-of select="@text:key2"/> + </xsl:element> + </xsl:if> + </xsl:element> + </xsl:template> + + + <xsl:template match="text:alphabetical-index-mark-end"> + <xsl:element name="indexterm"> + <xsl:attribute name="startref"> + <xsl:value-of select="@text:id"/> + </xsl:attribute> + <xsl:attribute name="class"> + <xsl:text disable-output-escaping="yes">endofrange</xsl:text> + </xsl:attribute> + </xsl:element> + </xsl:template> + + + <xsl:template match="text:alphabetical-index"> + <xsl:element name="index"> + <xsl:element name="title"> + <xsl:value-of select="text:index-body/text:index-title/text:p"/> + </xsl:element> + <xsl:apply-templates select="text:index-body"/> + </xsl:element> + </xsl:template> + + + <xsl:template match="text:index-body"> + <xsl:for-each select="text:p[@text:style-name = 'Index 1']"> + <xsl:element name="indexentry"> + <xsl:element name="primaryie"> + <xsl:value-of select="."/> + </xsl:element> + <xsl:if test="key('secondary_children', generate-id())"> + <xsl:element name="secondaryie"> + <xsl:value-of select="key('secondary_children', generate-id())"/> + </xsl:element> + </xsl:if> + </xsl:element> + </xsl:for-each> + </xsl:template> + +</xsl:stylesheet> + diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/htmltosoff.xsl b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/htmltosoff.xsl new file mode 100644 index 000000000000..baf160c1449e --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/htmltosoff.xsl @@ -0,0 +1,174 @@ +<?xml version='1.0' encoding="UTF-8"?> +<!-- + + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + + Copyright 2000, 2010 Oracle and/or its affiliates. + + OpenOffice.org - a multi-platform office productivity suite + + This file is part of OpenOffice.org. + + OpenOffice.org is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + OpenOffice.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details + (a copy is included in the LICENSE file that accompanied this code). + + You should have received a copy of the GNU Lesser General Public License + version 3 along with OpenOffice.org. If not, see + <http://www.openoffice.org/license.html> + for a copy of the LGPLv3 License. + +--> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:office="http://openoffice.org/2000/office" + xmlns:style="http://openoffice.org/2000/style" + xmlns:text="http://openoffice.org/2000/text" + xmlns:table="http://openoffice.org/2000/table" + xmlns:draw="http://openoffice.org/2000/drawing" + xmlns:fo="http://www.w3.org/1999/XSL/Format" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:number="http://openoffice.org/2000/datastyle" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:chart="http://openoffice.org/2000/chart" + xmlns:dr3d="http://openoffice.org/2000/dr3d" + xmlns:math="http://www.w3.org/1998/Math/MathML" + xmlns:form="http://openoffice.org/2000/form" + xmlns:script="http://openoffice.org/2000/script" + > +<xsl:output method="xml" /> + + +<xsl:template match="/"> + <xsl:apply-templates /> +</xsl:template> + +<xsl:template match="html"> + + <office:document-content xmlns:office="http://openoffice.org/2000/office" + xmlns:style="http://openoffice.org/2000/style" + xmlns:text="http://openoffice.org/2000/text" + xmlns:table="http://openoffice.org/2000/table" + xmlns:draw="http://openoffice.org/2000/drawing" + xmlns:fo="http://www.w3.org/1999/XSL/Format" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:number="http://openoffice.org/2000/datastyle" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:chart="http://openoffice.org/2000/chart" + xmlns:dr3d="http://openoffice.org/2000/dr3d" + xmlns:math="http://www.w3.org/1998/Math/MathML" + xmlns:form="http://openoffice.org/2000/form" + xmlns:script="http://openoffice.org/2000/script" + office:class="text" office:version="1.0"> + +<office:script/> + <office:font-decls> + <style:font-decl style:name="Letter Gothic" fo:font-family="'Letter Gothic'" style:font-family-generic="modern" style:font-pitch="fixed"/> + <style:font-decl style:name="Arial Unicode MS" fo:font-family="'Arial Unicode MS'" style:font-pitch="variable"/> + <style:font-decl style:name="HG Mincho Light J" fo:font-family="'HG Mincho Light J'" style:font-pitch="variable"/> + <style:font-decl style:name="CG Times" fo:font-family="'CG Times'" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-decl style:name="Thorndale" fo:font-family="Thorndale" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-decl style:name="Antique Olive" fo:font-family="'Antique Olive'" style:font-family-generic="swiss" style:font-pitch="variable"/> + <style:font-decl style:name="Arial Black" fo:font-family="'Arial Black'" style:font-family-generic="swiss" style:font-pitch="variable"/> + </office:font-decls> + <office:automatic-styles> + <style:style style:name="Table1" style:family="table"> + <style:properties style:width="16.999cm" table:align="margins"/> + </style:style> + <style:style style:name="Table1.A" style:family="table-column"> + <style:properties style:column-width="3.399cm" style:rel-column-width="13107*"/> + </style:style> + <style:style style:name="Table1.A1" style:family="table-cell"> + <style:properties fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="none" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000"/> + </style:style> + <style:style style:name="Table1.E1" style:family="table-cell"> + <style:properties fo:padding="0.097cm" fo:border="0.002cm solid #000000"/> + </style:style> + <style:style style:name="Table1.A2" style:family="table-cell"> + <style:properties fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.002cm solid #000000"/> + </style:style> + <style:style style:name="Table1.E2" style:family="table-cell"> + <style:properties fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000" fo:border-top="none" fo:border-bottom="0.002cm solid #000000"/> + </style:style> + <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard"> + <style:properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"/> + </style:style> + <style:style style:name="P2" style:family="paragraph" style:parent-style-name="Table Contents"> + <style:properties style:font-name="Arial Black" fo:font-size="20pt"/> + </style:style> + </office:automatic-styles> + + + + + + <office:body> + <text:sequence-decls> + <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> + <text:sequence-decl text:display-outline-level="0" text:name="Table"/> + <text:sequence-decl text:display-outline-level="0" text:name="Text"/> + <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> + </text:sequence-decls> + + <xsl:apply-templates/> + </office:body> + </office:document-content> + +</xsl:template> + +<xsl:template match="body"> + <xsl:apply-templates /> +</xsl:template> + + + +<xsl:template match="p"> + <xsl:for-each select="."> + <text:p text:style-name="P1"> + <!--<xsl:value-of select="."/>--> + <xsl:apply-templates /> + </text:p> + </xsl:for-each> +</xsl:template> + +<xsl:template match="br"> + <xsl:if test="ancestor::p"> + <xsl:text disable-output-escaping="yes"></text:p> <text:p text:style-name="P1"></xsl:text> + </xsl:if> +</xsl:template> + +<xsl:template match="table"> + <xsl:for-each select="."> + <table:table table:name="Table1" table:style-name="Table1"> + <table:table-column table:style-name="Table1.A" table:number-columns-repeated="5"/> + <xsl:apply-templates/> + </table:table> + </xsl:for-each> +</xsl:template> + +<xsl:template match="tr"> + <xsl:for-each select="."> + <table:table-row> + <xsl:apply-templates/> + </table:table-row> + </xsl:for-each> +</xsl:template> + +<xsl:template match="td"> + <xsl:for-each select="."> + <table:table-cell table:style-name="Table1.A1" table:value-type="string"> + <text:p text:style-name="P1"> + <xsl:value-of select="."/> + </text:p> + </table:table-cell> + </xsl:for-each> +</xsl:template> + + + +</xsl:stylesheet> diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/makefile.mk b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/makefile.mk new file mode 100644 index 000000000000..06e0d14909dc --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/makefile.mk @@ -0,0 +1,32 @@ +#*************************************************************************** +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#*************************************************************************** + +TARGET=xmrg_jooxcx_xslt +PRJ=../../../../../../.. + +.INCLUDE : ant.mk +ALLTAR: ANTBUILD diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/package.html b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/package.html new file mode 100644 index 000000000000..0a689fb47cda --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/package.html @@ -0,0 +1,65 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<!-- + + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + + Copyright 2000, 2010 Oracle and/or its affiliates. + + OpenOffice.org - a multi-platform office productivity suite + + This file is part of OpenOffice.org. + + OpenOffice.org is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + OpenOffice.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details + (a copy is included in the LICENSE file that accompanied this code). + + You should have received a copy of the GNU Lesser General Public License + version 3 along with OpenOffice.org. If not, see + <http://www.openoffice.org/license.html> + for a copy of the LGPLv3 License. + +--> +<HTML> +<HEAD> + <TITLE>org.openoffice.xmerge.converter.xml.xslt package</TITLE> +</HEAD> +<BODY> +<P>Provides the tools for doing the conversion of StarWriter XML to +and from supported formats, through the use of an XSLT +transformation.</P> +<P>It follows the {@link org.openoffice.xmerge} +framework for the conversion process.</P> +<P>This converter does not currently support merge.</P> +<P><FONT FACE="Times New Roman, serif"><FONT SIZE=5><B>XSLT +Transformation</B></FONT></FONT></P> +<p>The converter makes use +of one or more XSLT style sheets, which are used in the +DocumentSerializer and DocumentDeserializer, to perform the actual +translations. The location of these stylesheets is extracted from the {@link org.openoffice.xmerge.util.registry.ConverterInfo ConverterInfo} data structure, and are specified using the optional converter-xslt-serialize and converter-xsltdeserialize tags in a plugins converter.xml file. Please refer to the SDK document for more information about how to implement a Plugin Configuration XML File for a specific plugin. +A sample OpenOffice to Html stylesheet and Html to +Openffice stylesheet, has been provided as a sample implementation. +The converter also makes use of an XsltPlugin.properties file, which may be edited by the user to provide MIME-TYPE to file extension mappings. This file is used by the {@link org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl getDeviceFileExtension} method. +</p> + +<H2>TODO list</H2> + +<p><ol> +<li>Expand XSLT style sheets to support more office/html + capabilities</li> +<li>Add support for certain character codes, such as &nbsp + which currently causes the transformer to break.</li> +<li>Change the DocumentDeserializer transformer, so that the DOMResult is serialized using the xalan serializer and create an SxwDocument from the result</li> +</ol></p> + +@see org.openoffice.xmerge.util.registry + +</BODY> +</HTML> + + diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/sofftohtml.xsl b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/sofftohtml.xsl new file mode 100644 index 000000000000..761a66a3f6e4 --- /dev/null +++ b/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/sofftohtml.xsl @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + + Copyright 2000, 2010 Oracle and/or its affiliates. + + OpenOffice.org - a multi-platform office productivity suite + + This file is part of OpenOffice.org. + + OpenOffice.org is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + OpenOffice.org is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details + (a copy is included in the LICENSE file that accompanied this code). + + You should have received a copy of the GNU Lesser General Public License + version 3 along with OpenOffice.org. If not, see + <http://www.openoffice.org/license.html> + for a copy of the LGPLv3 License. + +--> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:style="http://openoffice.org/2000/style" xmlns:table="http://openoffice.org/2000/table" xmlns:text="http://openoffice.org/2000/text" xmlns:office="http://openoffice.org/2000/office" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" encoding="ISO-8859-1"/> <!--doctype-system=[<!ENTITY acirc "">] --> <xsl:strip-space elements="tokens"/> <xsl:template match="office:document"> <html> <xsl:apply-templates /> </html> </xsl:template> <xsl:template match="office:document-content"> <html> <xsl:apply-templates /> </html> </xsl:template> <xsl:template match="office:automatic-styles"> <style type="text/css"> p.Table-Heading{font-weight :bold;} <xsl:apply-templates /> </style> </xsl:template> <xsl:template match="office:styles"> </xsl:template> <xsl:template match="office:meta"> </xsl:template> <xsl:template match="office:settings"> </xsl:template> <xsl:template match="style:style"> <xsl:if test="@style:family ='paragraph'"> p.<xsl:value-of select="@style:name"/>{ <xsl:apply-templates />} </xsl:if> <xsl:if test="@style:family ='paragraph'"> p.<xsl:value-of select="@style:name"/>{ <xsl:if test="@style:parent-style-name='Table Heading'"> font-weight :bold;font-style:italic; </xsl:if> <xsl:apply-templates />} </xsl:if> <xsl:if test="@style:family ='table-cell'"> td.<xsl:value-of select="@style:name"/>{ <xsl:if test="@style:parent-style-name='Table Heading'"> font-weight :bold;font-style:italic; </xsl:if> <xsl:apply-templates />} </xsl:if> </xsl:template> <xsl:template match="style:properties"> <!--<xsl:param name="style" select="@fo:font-weight"/>--> <xsl:if test="@fo:font-weight"> font-weight :<xsl:value-of select="@fo:font-weight"/>; </xsl:if> <xsl:if test="@fo:font-style"> font-style :<xsl:value-of select="@fo:font-style"/>; </xsl:if> <xsl:if test="@style:font-name"> font-family :<xsl:value-of select="@style:font-name"/>; </xsl:if> <xsl:if test="@fo:font-size"> font-size : <xsl:value-of select="@fo:font-size"/>; </xsl:if> <xsl:if test="@style:text-underline='single'"> text-decoration :underline; </xsl:if> <xsl:if test="@style:text-crossing-out='single-line'"> text-decoration:line-through; </xsl:if> <xsl:if test="@fo:text-align='start'"> text-align :left </xsl:if> <xsl:if test="@fo:text-align='center'"> text-align :center </xsl:if> <xsl:if test="@fo:text-align='end'"> text-align :right </xsl:if> <!--<xsl:value-of select="$style"/>--> </xsl:template> <xsl:template match="office:body"> <xsl:apply-templates /> </xsl:template> <xsl:template match="table:table"> <table border="1" cellpadding="2" width="100%"> <xsl:apply-templates /> </table> </xsl:template> <xsl:template match="table:table-header-rows"> <th> <xsl:apply-templates /> </th> </xsl:template> <xsl:template match="table:table-row"> <tr> <xsl:apply-templates /> </tr> </xsl:template> <xsl:template match="table:table-cell"> <xsl:text disable-output-escaping="yes"><td class="</xsl:text> <xsl:value-of select="@table:style-name"/> <xsl:text disable-output-escaping="yes">"></xsl:text> <!--<xsl:value-of select="."/>--> <xsl:apply-templates /> <xsl:text disable-output-escaping="yes"></td></xsl:text> <!--<td width="20%"> <xsl:apply-templates /> </td>--> </xsl:template> <xsl:template match="text:p"> <xsl:if test="ancestor-or-self::table:table-cell"> <xsl:if test=".=''"> <br/> </xsl:if> </xsl:if> <xsl:text disable-output-escaping="yes"><p class="</xsl:text> <xsl:choose> <xsl:when test="@text:style-name ='Table Heading'"> Table-Heading </xsl:when> <xsl:otherwise> <xsl:value-of select="@text:style-name"/> </xsl:otherwise> </xsl:choose> <xsl:text disable-output-escaping="yes">"></xsl:text> <xsl:apply-templates/> <xsl:text disable-output-escaping="yes"></p></xsl:text> <!--<xsl:value-of select="."/>--> <!--<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>--> <!--<br/>--> </xsl:template> </xsl:stylesheet> |