Search in sources :

Example 1 with TGraph

use of eu.esdihumboldt.hale.common.align.tgraph.TGraph in project hale by halestudio.

the class XslRetype method createPropertiesFragment.

/**
 * Create a XSL fragment for populating the properties of a target instance.
 *
 * @param typeCell the associated type cell
 * @return the XSL fragment
 * @throws TransformationException if creating the fragment failed
 */
protected String createPropertiesFragment(final Cell typeCell) throws TransformationException {
    final TransformationTree tree = new TransformationTreeImpl(context().getAlignment(), typeCell);
    FunctionService functionService = new AlignmentFunctionService(context().getAlignment());
    /*
		 * Create the transformation graph derived from the transformation tree
		 * and perform context matching.
		 */
    /*
		 * XXX proxying multi-result nodes omitted for now, see
		 * proxyMultiResultNodes imlementation
		 */
    // final TGraph graph = new TGraphImpl(tree).proxyMultiResultNodes().performContextMatching();
    final TGraph graph = new TGraphImpl(tree, functionService).performContextMatching();
    // TODO tree as GraphML as informative annotation into XSLT?
    try {
        StringWriter propsOut = new StringWriter();
        try {
            AbstractTransformationTraverser trav = new RetypeTraverser(context(), propsOut, typeCell);
            trav.traverse(graph);
        } finally {
            propsOut.close();
        }
        return propsOut.toString();
    } catch (Exception e) {
        throw new TransformationException("Failed to create property transformations", e);
    }
}
Also used : TransformationTreeImpl(eu.esdihumboldt.hale.common.align.model.transformation.tree.impl.TransformationTreeImpl) TransformationException(eu.esdihumboldt.hale.common.align.transformation.function.TransformationException) StringWriter(java.io.StringWriter) AbstractTransformationTraverser(eu.esdihumboldt.hale.io.xslt.transformations.base.AbstractTransformationTraverser) TransformationTree(eu.esdihumboldt.hale.common.align.model.transformation.tree.TransformationTree) FunctionService(eu.esdihumboldt.hale.common.align.service.FunctionService) AlignmentFunctionService(eu.esdihumboldt.hale.common.align.service.impl.AlignmentFunctionService) TGraphImpl(eu.esdihumboldt.hale.common.align.tgraph.impl.TGraphImpl) AlignmentFunctionService(eu.esdihumboldt.hale.common.align.service.impl.AlignmentFunctionService) TGraph(eu.esdihumboldt.hale.common.align.tgraph.TGraph) TransformationException(eu.esdihumboldt.hale.common.align.transformation.function.TransformationException)

Aggregations

TransformationTree (eu.esdihumboldt.hale.common.align.model.transformation.tree.TransformationTree)1 TransformationTreeImpl (eu.esdihumboldt.hale.common.align.model.transformation.tree.impl.TransformationTreeImpl)1 FunctionService (eu.esdihumboldt.hale.common.align.service.FunctionService)1 AlignmentFunctionService (eu.esdihumboldt.hale.common.align.service.impl.AlignmentFunctionService)1 TGraph (eu.esdihumboldt.hale.common.align.tgraph.TGraph)1 TGraphImpl (eu.esdihumboldt.hale.common.align.tgraph.impl.TGraphImpl)1 TransformationException (eu.esdihumboldt.hale.common.align.transformation.function.TransformationException)1 AbstractTransformationTraverser (eu.esdihumboldt.hale.io.xslt.transformations.base.AbstractTransformationTraverser)1 StringWriter (java.io.StringWriter)1