diff --git a/laws-modules/pom.xml b/laws-modules/pom.xml index 2dca17bf..adc703c1 100644 --- a/laws-modules/pom.xml +++ b/laws-modules/pom.xml @@ -160,5 +160,15 @@ jaxen 1.2.0 + + net.sourceforge.jeuclid + jeuclid-core + 3.1.9 + + + org.apache.poi + poi-ooxml-schemas + 3.17 + \ No newline at end of file diff --git a/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java b/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java index ac9fd0b8..e072b07b 100644 --- a/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java +++ b/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java @@ -198,17 +198,17 @@ public class FileSpiltService { //} else if (child instanceof CTOMath) { CTOMath ctoMath = (CTOMath) child; - stringBuilder.append(ctoMath.xmlText()); + //stringBuilder.append(ctoMath.xmlText()); // 处理word中存在的公式成mathML格式 - //handleParagraphOMath(stringBuilder, ctoMath); + String imageName = OmmlUtils.convertOmathToPng(ctoMath.xmlText()); if (messageList.size() > 0) { - addItermsConditionsMath(messageList.get(messageList.size() - 1), itemValList, stringBuilder.toString()); + addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, imageName); } } else if (child instanceof CTOMathPara) { CTOMathPara ctoMathPara = (CTOMathPara) child; - stringBuilder.append(ctoMathPara.xmlText()); + String imageName = OmmlUtils.convertOmathToPng(ctoMathPara.xmlText()); if (messageList.size() > 0) { - addItermsConditionsMath(messageList.get(messageList.size() - 1), itemValList, stringBuilder.toString()); + addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, imageName); } } } @@ -276,22 +276,6 @@ public class FileSpiltService { continue; } } - //if (StringUtils.isNotEmpty(p.getNumLevelText()) && p.getNumLevelText().indexOf(".") > 0) { - // String numberParent = p.getNumLevelText().substring(0, p.getNumLevelText().lastIndexOf(".")).replaceAll("%",""); - // if (numberMap.containsKey(numberParent)) { - // Integer numbernow = (Integer) numberMap.get(numberParent) + 1; - // if (messageList != null && !messageList.isEmpty() && messageList.get(messageList.size() - 1).getItemNum().equals(numberParent + "." + String.valueOf(numbernow))) { - // numberMap.put(numberParent, numbernow + 1); - // paragraphString = numberParent + "." + String.valueOf(numbernow + 1) + paragraphString; - // } else { - // numberMap.put(numberParent, numbernow); - // paragraphString = numberParent + "." + String.valueOf(numbernow) + paragraphString; - // } - // } else { - // numberMap.put(numberParent, 1); - // paragraphString = numberParent + ".1" + paragraphString; - // } - //} if (messageNumber == 0) { //ptest = Pattern.compile("^1\\s{0,50}范围"); Matcher matcher = RANGE_PATTERN_1.matcher(paragraphString); @@ -477,32 +461,6 @@ public class FileSpiltService { return ""; } - /** - * 处理公式 - * - * @param content - * @param child - */ - private static void handleParagraphOMath(StringBuilder content, CTOMath child) { - log.info(">> 开始解析段落中的CTOMath公式"); - //将word中的omml格式转换成mathML - String mathMLFromNode = MathmlUtils.convertOMML2MML(child.xmlText()); - content.append(mathMLFromNode); - } - - /** - * 处理公式(将word中的omML格式的公式转换成mathML格式的工单) - * - * @param content - * @param child - */ - private static void handleParagraphOMath(StringBuilder content, CTOMathPara child) { - log.info(">> 开始解析段落中的CTOMathPara公式"); - //将word中的omml格式转换成mathML - String mathMLFromNode = MathmlUtils.convertOMML2MML(child.xmlText()); - content.append(mathMLFromNode); - } - /** * 通过传递过来的编号,得出下次可能出现的编号 * @@ -1158,6 +1116,15 @@ public class FileSpiltService { return tableToHtmlStr.toString(); } + // 像每个条款中依次插入每一段的内容 + private void addItermsMathImage(SarFileSplitItemsEO message, List itemsValList, String imageName) { + String path = splitUrl + imageName; + String imgConVal = ""; + message.getItemsCondi().add(imgConVal); + message.setItemContent(message.getItemContent() + imgConVal); + itemsValList.add(getSplitItemsValObject(message.getId(), SplitFilePragraTypeEnum.IMG.getValue(), path, message.getItemsCondi().size(), null)); + } + // 像每个条款中依次插入每一段的内容 private void addItermsConditionsImage(SarFileSplitItemsEO message, List itemsValList, XWPFParagraph p, List imageBundleList) { for (String pictureId : imageBundleList) { diff --git a/laws-modules/src/main/java/com/jero/modules/split/service/impl/SarFileSplitMenuEOServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/split/service/impl/SarFileSplitMenuEOServiceImpl.java index 5a9f5871..8d5a0b0f 100644 --- a/laws-modules/src/main/java/com/jero/modules/split/service/impl/SarFileSplitMenuEOServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/split/service/impl/SarFileSplitMenuEOServiceImpl.java @@ -126,7 +126,7 @@ public class SarFileSplitMenuEOServiceImpl extends ServiceImpl menuIds = new ArrayList<>(); SarFileSplitMenuEO sarMenuEO = new SarFileSplitMenuEO(); sarMenuEO.setId(id); diff --git a/laws-modules/src/main/java/com/jero/modules/split/util/ImageParse.java b/laws-modules/src/main/java/com/jero/modules/split/util/ImageParse.java new file mode 100644 index 00000000..93951ad0 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/split/util/ImageParse.java @@ -0,0 +1,54 @@ +package com.jero.modules.split.util; + +import com.jero.common.util.MinioUtil; +import com.jero.common.util.UUIDUtils; +import org.apache.commons.io.IOUtils; +import org.springframework.beans.factory.annotation.Value; + +import java.io.ByteArrayInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; + +public class ImageParse { + @Value("${jero.path.uploadCos}") + private String filePathCos; + @Value("${jero.splitUrl}") + private String splitUrl; + + private int number = 0; +// private String targetDir; + + public ImageParse() { + super(); +// this.targetDir = targetDir; + } + + public String parse(byte[] data, String extName) { + String imageName = UUIDUtils.randomUUID10() + extName; + + String filepathandname = filePathCos + "/" + imageName; + MinioUtil.uploadByte(data, filepathandname); + return imageName; + } + + public String parse(InputStream in, String extName) { + if (extName.lastIndexOf(".") > -1) { + extName = extName.substring(extName.lastIndexOf(".") + 1); + } + String filename = "image_" + (number++) + "." + extName; +// File target = new File(targetDir); +// if (!target.exists()) { +// target.mkdirs(); +// } + + try { + IOUtils.copy(in, new FileOutputStream(filename)); + } catch (IOException e) { + e.printStackTrace(); + } + return filename; + } + + +} diff --git a/laws-modules/src/main/java/com/jero/modules/split/util/MathmlUtils.java b/laws-modules/src/main/java/com/jero/modules/split/util/MathmlUtils.java deleted file mode 100644 index a0d73c17..00000000 --- a/laws-modules/src/main/java/com/jero/modules/split/util/MathmlUtils.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.jero.modules.split.util; - -import javax.xml.transform.*; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; -import java.io.InputStream; -import java.io.StringReader; -import java.io.StringWriter; - -/** - * @author liJiaRao - * @date 2024-01-03 15:36 - */ -public class MathmlUtils { - /** - * Description: xsl转换器 - */ - public static String xslConvert(String s, String xslpath, URIResolver uriResolver) { - TransformerFactory tFac = TransformerFactory.newInstance(); - if (uriResolver != null) - tFac.setURIResolver(uriResolver); - StreamSource xslSource = new StreamSource(MathmlUtils.class.getResourceAsStream(xslpath)); - StringWriter writer = new StringWriter(); - try { - Transformer t = tFac.newTransformer(xslSource); - Source source = new StreamSource(new StringReader(s)); - Result result = new StreamResult(writer); - t.transform(source, result); - } catch (TransformerException e) { - e.printStackTrace(); - } - return writer.getBuffer().toString(); - } - - /** - * Description: 将mathml转为latx - * @param mml - * @return - */ - public static String convertMML2Latex(String mml) { - mml = mml.substring(mml.indexOf("?>") + 2, mml.length()); //去掉xml的头节点 - URIResolver r = new URIResolver() { //设置xls依赖文件的路径 - @Override - public Source resolve(String href, String base) throws TransformerException { - InputStream inputStream = MathmlUtils.class.getResourceAsStream("/conventer/mml2tex/" + href); - return new StreamSource(inputStream); - } - }; - String latex = xslConvert(mml, "/conventer/mml2tex/mmltex.xsl", r); - if (latex != null && latex.length() > 1) { - latex = latex.substring(1, latex.length() - 1); - } - return latex; - } - - /** - * Description: office mathml转为mml - * @param xml - * @return - */ - public static String convertOMML2MML(String xml) { - xml = "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 2\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 3\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 4\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 5\n" + - " \n" + - " \n" + - " \n" + - " 6\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " + \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " sin(x)\n" + - " \n" + - " \n" + - " \n" + - "\n"; - String result = xslConvert(xml, "/conventer/OMML2MML.XSL", null); - return result; - } -} diff --git a/laws-modules/src/main/java/com/jero/modules/split/util/OmmlUtils.java b/laws-modules/src/main/java/com/jero/modules/split/util/OmmlUtils.java index 57905ed0..4817c8c7 100644 --- a/laws-modules/src/main/java/com/jero/modules/split/util/OmmlUtils.java +++ b/laws-modules/src/main/java/com/jero/modules/split/util/OmmlUtils.java @@ -1,18 +1,15 @@ package com.jero.modules.split.util; -import cn.hutool.poi.word.WordUtil; -import org.apache.xmlbeans.impl.jam.provider.ResourcePath; +import net.sourceforge.jeuclid.context.LayoutContextImpl; +import net.sourceforge.jeuclid.context.Parameter; +import net.sourceforge.jeuclid.converter.Converter; +import org.apache.xmlbeans.XmlObject; +import org.w3c.dom.Document; +import org.w3c.dom.Node; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; -import java.io.File; -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; +import java.io.*; import java.net.URL; /** @@ -20,29 +17,69 @@ import java.net.URL; * @date 2023-11-09 9:51 */ public class OmmlUtils { - /** - * 将word文档中公式格式为omML转换为mathMl - * @param omML - * @return - */ - public static String getMathMLFromNode(String omML) { - //通过word中的xsl转成器解析omml公式格式 - //URL resourceUrl = ResourcePath.class.getClassLoader().getResource("OMML2MML.XSL"); - //File file = new File(resourceUrl.getPath()); - StreamSource xslSource = new StreamSource(MathmlUtils.class.getResourceAsStream("conventer/OMML2MML.XSL")); - StringWriter writer = new StringWriter(); + + public static String convertOmathToPng(String oriMathXmlStr) { + ImageParse imageParser = new ImageParse(); + Document document = null; try { - Transformer t = TransformerFactory.newInstance().newTransformer(xslSource); - Source sources = new StreamSource(new StringReader(omML)); - StreamResult result = new StreamResult(writer); - t.transform(sources, result); - } catch (TransformerException e) { + System.out.println("oriMathXmlStrxxxxxxxxxxxxxxxxxxxxxxx : " + oriMathXmlStr); + XmlObject xmlObject = XmlObject.Factory.parse(oriMathXmlStr); + String mathMLStr = getMathMLFromNode(xmlObject.getDomNode()); + System.out.println("xxxxxxxxxxxxxxxxxxxxxxx : " + mathMLStr); + document = W3cNodeUtil.xmlStr2Node(mathMLStr, "utf-16"); + return documentToImageHTML(document, imageParser); + } catch (Exception e) { e.printStackTrace(); } - String mathML = writer.getBuffer().toString(); - mathML = mathML.replaceAll("xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\"", ""); - mathML = mathML.replaceAll("xmlns:mml", "xmlns"); - mathML = mathML.replaceAll("mml:", ""); + return null; + } + + /** + * 直接转node有等号会出问题,先转成xml的string,再转成mathML的字符串 + * + * @param node + * @return + * @throws IOException + * @throws TransformerException + */ + private static String getMathMLFromNode(Node node) throws IOException, TransformerException { + ClassLoader classLoader = OmmlUtils.class.getClassLoader(); + URL url = classLoader.getResource("xsl/OMML2MML.XSL"); + File xslFile = null; + if (url != null) { + try { + xslFile = new File(url.toURI()); + } catch (Exception e) { + e.printStackTrace(); + } + } + StreamSource streamSource = new StreamSource(xslFile); + String s = W3cNodeUtil.node2XmlStr(node); + //String s = "fx=a0+n=1ancosnπxL+bnsinnπxL"; + String mathML = W3cNodeUtil.xml2Xml(s, streamSource); + if (mathML != null) { + mathML = mathML.replaceAll("xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\"", ""); + mathML = mathML.replaceAll("xmlns:mml", "xmlns"); + mathML = mathML.replaceAll("mml:", ""); + } return mathML; } + + private static String documentToImageHTML(Document document, ImageParse imageParser) { + try { + Converter mathMLConvert = Converter.getInstance(); + LayoutContextImpl localLayoutContextImpl = new LayoutContextImpl(LayoutContextImpl.getDefaultLayoutContext()); + localLayoutContextImpl.setParameter(Parameter.MATHSIZE, 50); + ByteArrayOutputStream os = new ByteArrayOutputStream(); + mathMLConvert.convert(document, os, "image/png", localLayoutContextImpl); + String pngName = imageParser.parse(os.toByteArray(), ".png"); + os.close(); + return pngName; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + } diff --git a/laws-modules/src/main/java/com/jero/modules/split/util/ParagraphChildOrderManager.java b/laws-modules/src/main/java/com/jero/modules/split/util/ParagraphChildOrderManager.java index b5c4ab4f..69836bbe 100644 --- a/laws-modules/src/main/java/com/jero/modules/split/util/ParagraphChildOrderManager.java +++ b/laws-modules/src/main/java/com/jero/modules/split/util/ParagraphChildOrderManager.java @@ -1,23 +1,14 @@ package com.jero.modules.split.util; -import cn.hutool.poi.word.WordUtil; import lombok.extern.slf4j.Slf4j; import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFRun; import org.apache.xmlbeans.XmlCursor; -import org.dom4j.Document; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.dom4j.Node; -import org.dom4j.io.SAXReader; import org.openxmlformats.schemas.officeDocument.x2006.math.CTOMath; import org.openxmlformats.schemas.officeDocument.x2006.math.CTOMathPara; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; -import javax.xml.transform.*; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; -import java.io.*; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -60,6 +51,14 @@ public class ParagraphChildOrderManager { xmlcursor.pop(); } } + if (paragraph.getCTP().xmlText().contains("m:oMath")) { + for (XWPFRun run : paragraph.getRuns()) { + String xmlText = run.getCTR().xmlText(); + if (xmlText.contains("m:oMath")) { + System.out.println(xmlText); + } + } + } } public List getChildList() { @@ -97,103 +96,21 @@ public class ParagraphChildOrderManager { return runsOrMathList; } } - - public static String parseParagraph(XWPFParagraph xwpfParagraph) { - CTP ctp = xwpfParagraph.getCTP(); - String xmlText = ctp.xmlText(); - StringBuilder sb = new StringBuilder(); -// if (xmlText.contains("")) { - - //段落文本内容 - sb.append(xwpfParagraph.getParagraphText()); - //段落公式解析 - //得到根节点的值 - SAXReader saxReader = new SAXReader(); - //将String类型的字符串转换成XML文本对象 - Document doc = null; - try { - doc = saxReader.read(new ByteArrayInputStream(xmlText.getBytes())); - } catch (DocumentException e) { - e.printStackTrace(); + private Node getChildNode(Node node, String nodeName) { + if (!node.hasChildNodes()) { + return null; } - Element root = doc.getRootElement(); - // 一个段落多个表达式解析 - //用xpath得到OMML节点 - List nodes = root.selectNodes("//m:oMath"); - if (nodes != null && !nodes.isEmpty()) { - for (Node node : nodes) { - /** - * OMML -> MathML -> LaTex - * Office在安装目录中提供了将OMML转为MathML的xsl工具:MML2OMML.XSL - * MathML转LaTex使用网上找到另一个xsl工具mmltex.xsl。 - */ - String xml = node.asXML(); - //xml转 mathml - String mathml = convertOMML2MML(xml); - //mathml转latx - String latex = convertMML2Latex(mathml); - sb.append(latex); - log.info("latex表达式:{}",latex); + NodeList childNodes = node.getChildNodes(); + for (int i = 0; i < childNodes.getLength(); i++) { + Node childNode = childNodes.item(i); + if (nodeName.equals(childNode.getNodeName())) { + return childNode; + } + childNode = getChildNode(childNode, nodeName); + if (childNode != null) { + return childNode; } } - log.info("公式个数:{},解析内容:{}",nodes.size(),sb.toString()); - return sb.toString(); - } - - /** - *

Description: 将mathml转为latx

- * @param mml mathml字符串 - * @return - */ - public static String convertMML2Latex(String mml){ - mml = mml.substring(mml.indexOf("?>")+2, mml.length()); //去掉xml的头节点 - URIResolver r = new URIResolver(){ //设置xls依赖文件的路径 - @Override - public Source resolve(String href, String base) throws TransformerException { - File f = new File("/conventer/mml2tex/" + href); - InputStream inputStream = WordUtil.class.getResourceAsStream("/conventer/mml2tex/" + href); - return new StreamSource(inputStream); - } - }; - String latex = xslConvert(mml, "/conventer/mml2tex/mmltex.xsl", r); - if(latex != null && latex.length() > 1){ - latex = latex.substring(1, latex.length() - 1); - } - return latex; - } - /** - *

Description: office xml转为mathml

- * @param xml 公式xml - * @return - */ - public static String convertOMML2MML(String xml){ - // 进行转换的过程中需要借助这个文件,一般来说本机安装office就会有这个文件,找到就可以 - String result = xslConvert(xml, "/conventer/OMML2MML.XSL", null); - return result; - } - - /** - * Description: xsl转换器

- * @param s 公式xml字符串 - * @param xslpath 转换器路径 - * @param uriResolver xls依赖文件 - * @return - */ - public static String xslConvert(String s, String xslpath, URIResolver uriResolver){ - TransformerFactory tFac = TransformerFactory.newInstance(); - if(uriResolver != null) { - tFac.setURIResolver(uriResolver); - } - StreamSource xslSource = new StreamSource(WordUtil.class.getResourceAsStream(xslpath)); - StringWriter writer = new StringWriter(); - try { - Transformer t = tFac.newTransformer(xslSource); - Source source = new StreamSource(new StringReader(s)); - Result result = new StreamResult(writer); - t.transform(source, result); - } catch (TransformerException e) { - log.error(e.getMessage(), e); - } - return writer.getBuffer().toString(); + return null; } } diff --git a/laws-modules/src/main/java/com/jero/modules/split/util/W3cNodeUtil.java b/laws-modules/src/main/java/com/jero/modules/split/util/W3cNodeUtil.java new file mode 100644 index 00000000..664bb512 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/split/util/W3cNodeUtil.java @@ -0,0 +1,120 @@ +package com.jero.modules.split.util; + +import org.apache.xmlbeans.XmlException; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import java.io.*; + +public class W3cNodeUtil { + + public static void main(String[] args) throws XmlException, UnsupportedEncodingException { + String oriMathXmlStr = "fx=a0+n=1ancosnπxL+bnsinnπxL"; + //oriMathXmlStr = new String(oriMathXmlStr.getBytes("gbk"), "utf-8"); + String s = OmmlUtils.convertOmathToPng(oriMathXmlStr); + System.out.printf(s); + } + + public static String node2XmlStr(Node node) { + Transformer transformer = null; + if (node == null) { + throw new IllegalArgumentException("node 不能为空.."); + } + try { + transformer = TransformerFactory.newInstance().newTransformer(); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + if (transformer != null) { + try { + StringWriter sw = new StringWriter(); + transformer.transform(new DOMSource(node), new StreamResult(sw)); + return sw.toString(); + } catch (TransformerException te) { + throw new RuntimeException(te.getMessage()); + } + } + return null; + } + + public static String xml2Xml(String xml, Source XSLSource) { + Transformer transformer = null; + if (xml == null) { + throw new IllegalArgumentException("node 不能为空.."); + } + try { + if (XSLSource == null) { + transformer = TransformerFactory.newInstance().newTransformer(); + } else { + transformer = TransformerFactory.newInstance().newTransformer(XSLSource); + } + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + if (transformer != null) { + try { + Source source = new StreamSource(new StringReader(xml)); + StringWriter sw = new StringWriter(); + transformer.transform(source, new StreamResult(sw)); + return sw.toString(); + } catch (TransformerException te) { + throw new RuntimeException(te); + } + } + return null; + } + + //MathML转成Document + public static Document xmlStr2Node(String xmlString, String encoding) { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + Document doc = null; + try { + InputStream is = new ByteArrayInputStream(xmlString.getBytes(encoding)); + doc = dbf.newDocumentBuilder().parse(is); + is.close(); + } catch (Exception e) { + e.printStackTrace(); + } + return doc; + } + + private static Node getChildNode(Node node, String nodeName) { + if (!node.hasChildNodes()) { + return null; + } + NodeList childNodes = node.getChildNodes(); + for (int i = 0; i < childNodes.getLength(); i++) { + Node childNode = childNodes.item(i); + if (nodeName.equals(childNode.getNodeName())) { + return childNode; + } + childNode = getChildNode(childNode, nodeName); + if (childNode != null) { + return childNode; + } + } + return null; + } + + public static Node getChildChainNode(Node node, String... nodeName) { + Node childNode = node; + for (int i = 0; i < nodeName.length; i++) { + String tmp = nodeName[i]; + childNode = getChildNode(childNode, tmp); + if (childNode == null) { + return null; + } + } + return childNode; + } + +} diff --git a/laws-modules/src/main/resources/conventer/OMML2MML.XSL b/laws-modules/src/main/resources/xsl/OMML2MML.XSL similarity index 100% rename from laws-modules/src/main/resources/conventer/OMML2MML.XSL rename to laws-modules/src/main/resources/xsl/OMML2MML.XSL diff --git a/laws-single-startup/src/main/resources/conventer/OMML2MML.XSL b/laws-single-startup/src/main/resources/conventer/OMML2MML.XSL deleted file mode 100644 index b46ae33b..00000000 --- a/laws-single-startup/src/main/resources/conventer/OMML2MML.XSL +++ /dev/null @@ -1,2068 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ˘ - - ¸ - - ` - - - - - - - . - - ˙ - - ˝ - - ´ - - ~ - - ˜ - - ¨ - - ˇ - - ^ - - ¯ - - _ - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - left - - - right - - - - - - - - - - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0in - - - 0in - - - 0in - - - - - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - false - - - - - - - - - - - - - - - - - - - off - - - - - - - - - - - off - - - - - - - - - - - - - - off - - - - - - - - - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - 0pt - - - - right - - - left - - - - - right - - - left - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - 0 - - - - - - - - - - ¯ - - - - - - - - - - _ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - - - - - - - - - - - - - normal - - - - - - - - monospace - sans-serif-italic - bold-sans-serif - sans-serif-bold-italic - sans-serif - bold-fraktur - fraktur - double-struck - bold-script - script - bold - italic - normal - bold-italic - - - - - - bold - normal - - - - - normal - italic - - - - - - - - - - - - - - - - - - - - - - - - italic - - - bold - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - 1 - - - - - - - - - - - - - - - - - - - - - - 1 - 0 - - - - - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - 0 - - - - - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - box - - - - - - - - - - - - - - - - - left right top bottom - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - 0 - -1 - - - - - - - - - - - - - 0 - 1 - - - - - - - - - - - - - 1 - 0 - - - diff --git a/laws-single-startup/src/main/resources/conventer/mml2tex/README b/laws-single-startup/src/main/resources/conventer/mml2tex/README deleted file mode 100644 index b5fdf158..00000000 --- a/laws-single-startup/src/main/resources/conventer/mml2tex/README +++ /dev/null @@ -1,97 +0,0 @@ -README for the XSLT MathML Library - -XSLT MathML Library is a set of XSLT stylesheets to transform -MathML 2.0 to LaTeX. - -For more information, see -http://www.raleigh.ru/MathML/mmltex/index.php?lang=en - -Manifest --------- - -README this file -mmltex.xsl -tokens.xsl -glayout.xsl -scripts.xsl -tables.xsl -entities.xsl -cmarkup.xsl - -Use ---- - -There are two ways of using the library: - - * Use a local copy of the library. - - 1. Download the distribution (see below). - - 2. Unpack the distribution, using unzip. - - 3. In your stylesheet import or include either the main - stylesheet, mmltex.xsl, or the stylesheet module you - wish to use, such as tokens.xsl. This example assumes - that the distribution has been extracted into the same - directory as your own stylesheet: - - - - * Import or include either the main stylesheet, or the - stylesheet module you wish to use, directly from the library - website; http://www.raleigh.ru/MathML/mmltex/. For example: - - - -Obtaining The Library ---------------------- - -The XSLT MathML Library is available for download as: - - * Zip file: http://www.raleigh.ru/MathML/mmltex/mmltex.zip - -Copyright ---------- - -Copyright (C) 2001, 2002 Vasil Yaroshevich - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the ``Software''), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -Except as contained in this notice, the names of individuals -credited with contribution to this software shall not be used in -advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization -from the individuals in question. - -Any stylesheet derived from this Software that is publically -distributed will be identified with a different name and the -version strings in any derived Software will be changed so that -no possibility of confusion between the derived package and this -Software will exist. - -Warranty --------- - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL NORMAN WALSH OR ANY OTHER -CONTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Contacting the Author ---------------------- - -These stylesheets are maintained by Vasil Yaroshevich, . diff --git a/laws-single-startup/src/main/resources/conventer/mml2tex/cmarkup.xsl b/laws-single-startup/src/main/resources/conventer/mml2tex/cmarkup.xsl deleted file mode 100644 index 9e72dda7..00000000 --- a/laws-single-startup/src/main/resources/conventer/mml2tex/cmarkup.xsl +++ /dev/null @@ -1,1093 +0,0 @@ - - - - - - - - - - - - - + - - i - - - - - / - - - - - - _{} - - - - - e^{i - - } - - - - - E - - - - - - - - \mathrm{} - - - - - - - - - - - - - ( - - - , - - ) - - - - - () - - - - - - - \left( - - \left[ - - - , - - - - \right) - - \right] - - - - - \left\{\right\} - - - - - ^{(-1)} - - - - - - - - \mathrm{lambda}\: - - .\: - - - - - - - - - - \circ - - - - -\mathrm{id} - - - - \mathop{\mathrm{ - - }} - - - - - - - - \begin{cases} - - - \end{cases} - - - - - & \text{if $ - - $} - \\ - - - - - & \text{otherwise} - - - - - \left\lfloor\frac{ - - }{ - - }\right\rfloor - - - - - - - - ! - - - - - - - \left( - \frac{ - - - }{ - - - } - \right) - - - - - \ - - \{ - - - - , - - - - - - , - - - - \} - - - - - - - - - - - - - - - - - - - - - - - - - - ( - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - ) - - - - - - - - - ^{ - - - - } - - - - - - - \mod - - - - - - - - - - ( - - - - \times - - - - - - - - - - ) - - - - - \sqrt - - [ - - ] - - { - - } - - - -\gcd - - - - - - - - \land - - - - - - - - - - \lor - - - - - - - - - - \mathop{\mathrm{xor}} - - - - - - \neg - - - - - - - - - - \implies - - - - - - - - \ - - - - - , - - - \colon - - - - - - - \left| - - \right| - - - - - \overline{} - - - -\Re - - -\Im - - - - \lfloor - - \rfloor - - - - - \lceil - - \rceil - - - - - - - - - = - - - - - - - - - - \neq - - - - - - - - - - > - - - - - - - - - - < - - - - - - - - - - \ge - - - - - - - - - - \le - - - - - - - - - - \equiv - - - - - - - - - - \approx - - - - - - - - | - - - - - - - - \int - - _{ - - } - - - ^{ - - } - - - - \,d - - - - - - - ^\prime - - - - \frac{ - - - d^{ - - } - - }{d - - ^{ - - } - - - d - - }{d - - } - - - } - - - - - D_{ - - - , - - } - - - - - \frac{\partial^{ - - - - - - - - + - - - + - - - - - - - - } - - }{ - - \partial - - - ^{ - - } - - - } - - - - - - - - - , - - - -\mathop{\mathrm{div}} - - -\nabla^2 - - - - \{\} - - - - - \left[\right] - - - - - - - \colon - - - - - - , - - - - - - - - - - - - \cup - - - - - - - - - - \cap - - - - - - - - \in - - - - - - - - - - \notin - - - - - - - - - - - - \subseteq - - - - - - - - - - \subset - - - - - - - - - - \nsubseteq - - - - - - - - - - \not\subset - - - - - - - - - - \setminus - - - - - - | - - | - - - - - - - - - \times - - - - - - - - ^{ - - } - - - - - \sum - - - - - \prod - - - - - _{ - - - = - - - } - - - ^{ - - } - - - - - - - - \lim_{ - - } - - - - - - \to - - - - - - - - - - - - \searrow - \nearrow - \rightarrow - \to - - - - - - - - \ - - - - - - - - - \ - - - - - - \mathrm{ - - \,} - - - - - - - \mathrm{ - - } - - - - - e^{} - - - - - \lg - - - - - - - \log_{ - - } - - - - - - - - \langle - - - , - - \rangle - - - -\sigma - - - - \sigma( - - )^2 - - - - - \langle - - ^{ - - }\rangle - - _{ - - } - - - - - - - \left(\begin{array}{c} - - - \\ - - \end{array}\right) - - - - - \begin{pmatrix} - - \end{pmatrix} - - - - - - - & - - \\ - - - - - \det - - - - - - - \begin{vmatrix} - - \end{vmatrix} - - - - - - - - ^T - - - - - - - - _{ - - - , - - } - - - - - - - - - \dot - - - - - - - - - - - -\mathbb{Z} - - -\mathbb{R} - - -\mathbb{Q} - - -\mathbb{N} - - -\mathbb{C} - - -\mathbb{P} - - -e - - -i - - -NaN - - -\mbox{true} - - -\mbox{false} - - -\emptyset - - -\pi - - -\gamma - - -\infty - - - - - - - ( - - - - - - - - - ) - - - - - - - ( - - - - - - - - ) - - - \ No newline at end of file diff --git a/laws-single-startup/src/main/resources/conventer/mml2tex/entities.xsl b/laws-single-startup/src/main/resources/conventer/mml2tex/entities.xsl deleted file mode 100644 index d62e9e79..00000000 --- a/laws-single-startup/src/main/resources/conventer/mml2tex/entities.xsl +++ /dev/null @@ -1,316 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/laws-single-startup/src/main/resources/conventer/mml2tex/glayout.xsl b/laws-single-startup/src/main/resources/conventer/mml2tex/glayout.xsl deleted file mode 100644 index 5aaa19d8..00000000 --- a/laws-single-startup/src/main/resources/conventer/mml2tex/glayout.xsl +++ /dev/null @@ -1,220 +0,0 @@ - - - - - - - - - - - - - - \genfrac{}{}{ - - - - ex - - - .05ex - - - - .2ex - - - - - - }{}{ - - - \frac{ - - - - \hfill - - - - \hfill - - }{ - - \hfill - - - - \hfill - - } - - - - - - \sqrt[ - - ]{ - - } - - - - exception 25: - \text{exception 25:} - - - - - - \sqrt{ - - } - - - - - - - \left - - - \ - - - - \left( - - - - - - - - - - - , - - - - - - - - - - - - - - - - - - - - - - - - \right - - - \ - - - - \right) - - - - - \phantom{ - - } - - - - - - \overline{ - - \hspace{.2em}|} - - - \sqrt{ - - } - - - \overline{) - - } - - - - - - - - - - - \colorbox[rgb]{ - - - - }{$ - - - \textcolor[rgb]{ - - - - }{ - - - - } - - - $} - - - - - - - - - \ No newline at end of file diff --git a/laws-single-startup/src/main/resources/conventer/mml2tex/mmltex.xsl b/laws-single-startup/src/main/resources/conventer/mml2tex/mmltex.xsl deleted file mode 100644 index 45c9e6f1..00000000 --- a/laws-single-startup/src/main/resources/conventer/mml2tex/mmltex.xsl +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $ - - $ - - - \ No newline at end of file diff --git a/laws-single-startup/src/main/resources/conventer/mml2tex/scripts.xsl b/laws-single-startup/src/main/resources/conventer/mml2tex/scripts.xsl deleted file mode 100644 index a81909e0..00000000 --- a/laws-single-startup/src/main/resources/conventer/mml2tex/scripts.xsl +++ /dev/null @@ -1,292 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - \overline{ - - - - - } - - - \overbrace{ - - - - - } - - - \underline{ - - - - - - } - - - \underbrace{ - - - - - - } - - - - - _{ - - }^{ - - } - - - \underset{ - - }{\overset{ - - }{ - - }} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \overline{ - - } - - - \overbrace{ - - } - - - - - ^{ - - } - - - \stackrel{ - - }{ - - } - - - - - - - - - - - \underline{ - - } - - - \underbrace{ - - } - - - - - _{ - - } - - - \underset{ - - }{ - - } - - - - - - { - - }_{ - - }^{ - - } - - - - { - - }^{ - - } - - - - { - - }_{ - - } - - - - - - {}_{ - - } - - - {}^{ - - } - - - - - - {} - - - _{ - - } - - - ^{ - - } - - - - - - - - - - - - - - {} - - - _{ - - } - - - ^{ - - } - - - - - - - \ No newline at end of file diff --git a/laws-single-startup/src/main/resources/conventer/mml2tex/tables.xsl b/laws-single-startup/src/main/resources/conventer/mml2tex/tables.xsl deleted file mode 100644 index e60592aa..00000000 --- a/laws-single-startup/src/main/resources/conventer/mml2tex/tables.xsl +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - - - \multicolumn{ - - }{c}{ - - } - - & - - - - - - - \hfill - - - - \hfill - - - - & - - - - - - - \\ - - - - - \begin{array}{ - - | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | - - } - - \hline - - - - \\ \hline - - \end{array} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/laws-single-startup/src/main/resources/conventer/mml2tex/tokens.xsl b/laws-single-startup/src/main/resources/conventer/mml2tex/tokens.xsl deleted file mode 100644 index dcf1af12..00000000 --- a/laws-single-startup/src/main/resources/conventer/mml2tex/tokens.xsl +++ /dev/null @@ -1,296 +0,0 @@ - - - - - - - - - - - - - - - \mathrm{ - - } - - - - - - - - - - - - - - - - - - - - - - \text{ - - } - - - - \phantom{\rule - - [- - - ] - - { - - 0ex - - - }{ - - 0ex - - - }} - - - - - - " - - - " - - - - - - \colorbox[rgb]{ - - - - }{$ - - - \textcolor[rgb]{ - - - - }{ - - - - - \mathrm{ - - - \mathbf{ - - - \mathit{ - - - \mathbit{ - - - \mathbb{ - - - { - - - \mathcal{ - - - \mathsc{ - - - \mathfrak{ - - - \mathsf{ - - - \mathbsf{ - - - \mathsfit{ - - - \mathbsfit{ - - - \mathtt{ - - - { - - - - - - } - - - } - - - $} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - , - - - - - - , - - - - - - - - - - - - - - - - - - - , - - - - - - - - - - - , - - - - - - - - - - - - - - 0,1,1 - 0,0,0 - 0,0,1 - 1,0,1 - .5,.5,.5 - 0,.5,0 - 0,1,0 - .5,0,0 - 0,0,.5 - .5,.5,0 - .5,0,.5 - 1,0,0 - .75,.75,.75 - 0,.5,.5 - 1,1,1 - 1,1,0 - - Exception at color template - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Exception at Hex2Decimal template - - - - - - - - - - - \ No newline at end of file