Commits

petermr committed cf384e1

added stylsheets

  • Participants
  • Parent commits 41f6b62

Comments (0)

Files changed (6)

src/main/java/org/xmlcml/cml/crystaleye/AbstractCrystaleyeVisitor.java

 		
 	}
 
+	protected List<String> getParameterList(String name) {
+		ensureParameterMaps();
+		return parameterListMap.get(name);
+		
+	}
+
 	private void registerFileFilter(Element fileFilterElement) {
 		fileFilterMethod = fileFilterElement.getAttributeValue(METHOD);
 		fileFilterValue = fileFilterElement.getValue();

src/main/java/org/xmlcml/cml/crystaleye/XPathVisitor.java

 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.util.List;
 
 import nu.xom.Document;
 import nu.xom.Element;
 
 import org.apache.log4j.Logger;
 import org.xmlcml.cml.base.CMLUtil;
+import org.xmlcml.cml.html.HtmlBody;
+import org.xmlcml.cml.html.HtmlHtml;
+import org.xmlcml.cml.html.HtmlTable;
 
 
 /** Splits document into components determined by XPath expression
 		if (xPath == null) {
 			throw new RuntimeException("must provide XPATH parameter for XPathVisitor");
 		}
+		List<String> xpathList = getParameterList(XPATH_NAME);
+		if (xpathList.size() > 1) {
+			return makeTable(xmlFile, xpathList);
+		} else {
+			return splitIntoSubdirectories(xmlFile);
+		}
+	}
+
+	private Document makeTable(File xmlFile, List<String> xpathList) {
+		if (true) {
+			throw new RuntimeException("NYI");
+		}
+//		HtmlHtml html = new HtmlHtml();
+//		HtmlBody body = html.ensureBody();
+//		HtmlTable table = new HtmlTable();
+//		body.appendChild(table);
+//		
+//		return new Document(html);
+		return null;
+	}
+
+	private Document splitIntoSubdirectories(File xmlFile) {
 		String s = getParameter(XPATH_DIRECTORY);
 		directoryName = (s == null) ? directoryName : s;
 		outputDirectory = xmlFile.getParentFile();

src/main/java/org/xmlcml/cml/crystaleye/supptext/ResolveCTFromName.java

 			throw new RuntimeException("Cannot parse document as CML-POS: "+xmlFile, e);
 		}
 		Document moleculesDocument = resolveMolecules(document);
-		CMLUtil.debug(moleculesDocument.getRootElement(), "DDD");
+//		CMLUtil.debug(moleculesDocument.getRootElement(), "DDD");
 		return moleculesDocument;
 	}
 
 			CrystaleyeUtil.extractTopLevelMoleculesWithNameButNoConnectionTable(document);
 
 		for (CMLMolecule origMolecule : origMoleculeList) {
-//			CMLMolecule molecule = (CMLMolecule) CMLBuilder.ensureCML(origMolecule);
-//			CMLMolecule translatedMolecule = getOpsinOscarIndexMolecule(molecule);
 			CMLMolecule translatedMolecule = getOpsinOscarIndexMolecule(origMolecule);
 			if (translatedMolecule != null) {
 				String smiles = new SMILESTool(translatedMolecule).write();
-//				System.err.println("SSS "+smiles);
 				addSMILESToDocument(origMolecule, smiles);
 			}
 		}
 
 	private void addSMILESToDocument(Element moleculeElement, String smiles) {
 		if (opsinOscarMolecule != null) {
-//			String smiles = new SMILESTool(opsinOscarMolecule).write();
 			CMLFormula formula = new CMLFormula();
 			formula.setInline(smiles);
 			formula.setConvention(CrystaleyeUtil.SMILES);
 			moleculeElement.appendChild(formula);
-//			((CMLElement)moleculeElement).debug("XXXXXXXXX");
 		}
 	}
 

src/main/resources/org/xmlcml/cml/crystaleye/dissolve.xsl

+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:cml="http://www.xml-cml.org/schema">
+
+<!-- 
+
+<PrepPhrase  sf="in CH3CN ( 500 mL )" id="prepphrase33">
+  <IN sf="in" role="IN" id="in34">in</IN> 
+- <NN sf="CH3CN ( 500  mL )" role="MOLECULE"  id="nn35">
+- <molecule id="molecule36"  xmlns="http://www.xml-cml.org/schema">
+- <formula concise="C 2  H 3 N 1" id="formula37">
+  <atomArray elementType="C H N" count="2.0 3.0  1.0" id="atomArray38"  /> 
+  </formula>
+  <name id="name39">CH3CN</name> 
+- <amount role="VOLUME"  id="amount40">
+  <scalar  dataType="xsd:double" units="units:millilitre"  id="scalar41">500.0</scalar> 
+  </amount>
+  <formula inline="C(C#N)([H])([H])[H]"  convention="SMILES" /> 
+  </molecule>
+  </NN>
+  </PrepPhrase> -->
+  
+  <xsl:template match="/">
+    <table border="1">
+   <tr>
+    <td>concise</td>
+    <td>smiles</td>
+    <td>name</td>
+    <td>amount</td>
+    <td>units</td>
+  </tr>
+      <xsl:apply-templates select="//PrepPhrase[IN[@role='IN']]//NN[@role='MOLECULE']/*[local-name()='molecule']"/>
+    </table>
+  </xsl:template>
+
+  <xsl:template match="*[local-name()='molecule']">
+  <tr>
+    <td><xsl:value-of select="*[local-name()='formula']/@concise"/></td>
+    <td><xsl:value-of select="*[local-name()='formula' and @convention='SMILES']/@inline"/></td>
+    <td><xsl:value-of select="*[local-name()='name']"/></td>
+    <td><xsl:value-of select="*[local-name()='amount']/*[local-name()='scalar']"/></td>
+    <td><xsl:value-of select="*[local-name()='amount']/*[local-name()='scalar']/@units"/></td>
+  </tr>
+ 
+  </xsl:template>
+
+  <xsl:template match="text()">
+ 
+  </xsl:template>
+
+
+</xsl:stylesheet>

src/main/resources/org/xmlcml/cml/crystaleye/solvent.xsl

+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:cml="http://www.xml-cml.org/schema">
+
+<!-- 
+
+<PrepPhrase  sf="in CH3CN ( 500 mL )" id="prepphrase33">
+  <IN sf="in" role="IN" id="in34">in</IN> 
+- <NN sf="CH3CN ( 500  mL )" role="MOLECULE"  id="nn35">
+- <molecule id="molecule36"  xmlns="http://www.xml-cml.org/schema">
+- <formula concise="C 2  H 3 N 1" id="formula37">
+  <atomArray elementType="C H N" count="2.0 3.0  1.0" id="atomArray38"  /> 
+  </formula>
+  <name id="name39">CH3CN</name> 
+- <amount role="VOLUME"  id="amount40">
+  <scalar  dataType="xsd:double" units="units:millilitre"  id="scalar41">500.0</scalar> 
+  </amount>
+  <formula inline="C(C#N)([H])([H])[H]"  convention="SMILES" /> 
+  </molecule>
+  </NN>
+  </PrepPhrase> -->
+  
+  <xsl:template match="/">
+    <table border="1">
+   <tr>
+    <td>concise</td>
+    <td>smiles</td>
+    <td>name</td>
+    <td>amount</td>
+    <td>units</td>
+  </tr>
+      <xsl:apply-templates select="//PrepPhrase[IN]/NN[@role='MOLECULE']/*[local-name()='molecule']"/>
+    </table>
+  </xsl:template>
+
+  <xsl:template match="*[local-name()='molecule']">
+  <tr>
+    <td><xsl:value-of select="*[local-name()='formula']/@concise"/></td>
+    <td><xsl:value-of select="*[local-name()='formula' and @convention='SMILES']/@inline"/></td>
+    <td><xsl:value-of select="*[local-name()='name']"/></td>
+    <td><xsl:value-of select="*[local-name()='amount']/*[local-name()='scalar']"/></td>
+    <td><xsl:value-of select="*[local-name()='amount']/*[local-name()='scalar']/@units"/></td>
+  </tr>
+ 
+  </xsl:template>
+
+  <xsl:template match="text()">
+ 
+  </xsl:template>
+
+
+</xsl:stylesheet>

src/main/resources/org/xmlcml/cml/crystaleye/wash.xsl

+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:cml="http://www.xml-cml.org/schema">
+
+<!-- 
+
+- <VerbPhrase sf="washed with brine" id="verbphrase98">
+    <VB sf="washed" role="WASH" id="vb99">washed</VB> 
+-   <PrepPhrase sf="with brine" id="prepphrase100">
+      <IN sf="with" role="WITH" id="in101">with</IN> 
+-     <NounPhrase sf="brine" id="nounphrase102">
+-       <NN sf="brine" role="MOLECULE" id="nn103">
+-         <molecule id="molecule104" xmlns="http://www.xml-cml.org/schema">
+            <name id="name105">brine</name> 
+          </molecule>
+        </NN>
+      </NounPhrase>
+    </PrepPhrase>
+  </VerbPhrase>
+--> 
+  <xsl:template match="/">
+    <table border="1">
+   <tr>
+    <td>concise</td>
+    <td>smiles</td>
+    <td>name</td>
+    <td>amount</td>
+    <td>units</td>
+  </tr>
+      <xsl:apply-templates select=
+          "//VerbPhrase[VB[@role='WASH']]/PrepPhrase[IN[@role='WITH']]//NN[@role='MOLECULE']/*[local-name()='molecule']"/>
+     </table>
+  </xsl:template>
+
+  <xsl:template match="*[local-name()='molecule']">
+  <tr>
+    <td><xsl:value-of select="*[local-name()='formula']/@concise"/></td>
+    <td><xsl:value-of select="*[local-name()='formula' and @convention='SMILES']/@inline"/></td>
+    <td><xsl:value-of select="*[local-name()='name']"/></td>
+    <td><xsl:value-of select="*[local-name()='amount']/*[local-name()='scalar']"/></td>
+    <td><xsl:value-of select="*[local-name()='amount']/*[local-name()='scalar']/@units"/></td>
+  </tr>
+ 
+  </xsl:template>
+
+  <xsl:template match="text()">
+ 
+  </xsl:template>
+
+
+</xsl:stylesheet>