| 1 | /* |
|---|
| 2 | Licensed to Plutext Pty Ltd under one or more contributor license agreements. |
|---|
| 3 | |
|---|
| 4 | * This file is part of docx4j. |
|---|
| 5 | |
|---|
| 6 | docx4j is licensed under the Apache License, Version 2.0 (the "License"); |
|---|
| 7 | you may not use this file except in compliance with the License. |
|---|
| 8 | |
|---|
| 9 | You may obtain a copy of the License at |
|---|
| 10 | |
|---|
| 11 | http://www.apache.org/licenses/LICENSE-2.0 |
|---|
| 12 | |
|---|
| 13 | Unless required by applicable law or agreed to in writing, software |
|---|
| 14 | distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|---|
| 16 | See the License for the specific language governing permissions and |
|---|
| 17 | limitations under the License. |
|---|
| 18 | |
|---|
| 19 | */ |
|---|
| 20 | package org.docx4j.model; |
|---|
| 21 | |
|---|
| 22 | import javax.xml.transform.TransformerException; |
|---|
| 23 | |
|---|
| 24 | import org.docx4j.convert.out.Converter; |
|---|
| 25 | import org.docx4j.openpackaging.packages.WordprocessingMLPackage; |
|---|
| 26 | import org.w3c.dom.Node; |
|---|
| 27 | import org.w3c.dom.NodeList; |
|---|
| 28 | |
|---|
| 29 | public abstract class Model { |
|---|
| 30 | |
|---|
| 31 | protected WordprocessingMLPackage wordMLPackage; |
|---|
| 32 | public void setWordMLPackage(WordprocessingMLPackage wordMLPackage) { |
|---|
| 33 | this.wordMLPackage = wordMLPackage; |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | /** |
|---|
| 37 | * Build the model from a DOM node. |
|---|
| 38 | * This is useful if the model is being built via |
|---|
| 39 | * XSLT, for the purposes of conversion to some other format. |
|---|
| 40 | * |
|---|
| 41 | * It is assumed the children of the structure being transformed |
|---|
| 42 | * have already been transformed, so they can be attached to |
|---|
| 43 | * the resulting structure and returned as-is. |
|---|
| 44 | * |
|---|
| 45 | * @param node |
|---|
| 46 | * @param children |
|---|
| 47 | * @throws TransformerException |
|---|
| 48 | */ |
|---|
| 49 | public abstract void build(Node node, NodeList children ) |
|---|
| 50 | throws TransformerException; |
|---|
| 51 | |
|---|
| 52 | /** |
|---|
| 53 | * Generate a JAXB OpenXML object from this structure. |
|---|
| 54 | * |
|---|
| 55 | * For conversion to other formats (eg HTML, XSL FO), refer to |
|---|
| 56 | * the ModelConverter implementations. |
|---|
| 57 | */ |
|---|
| 58 | public abstract Object toJAXB(); |
|---|
| 59 | |
|---|
| 60 | } |
|---|