⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pathbridge.java

📁 normkit is a set of tools supporting ontology learning. from xml,xsd to rdfs.
💻 JAVA
字号:
package it.itc.ectrl.normkit.common.NormMapModel;

import edu.unika.aifb.kaon.api.oimodel.Instance;
import edu.unika.aifb.kaon.api.KAONException;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.Element;

import it.itc.ectrl.normkit.common.*;

/**
 * Class representing a path bridge bridge for the Normalisation Map. Path bridge defines correspondence between a XML path abstracted in XPath model and RDF path abstracted in an RDFS conceptual model.
 *
 * RDF path is a sequence of Property Nodes connecting two RDF nodes.
 *
 * XML path is a sequence of axes connecting two XML nodes.
 *
 * Currently the implementation of D-Normalisation engines supports only "one-step-path" on the RDFS site, therefore the RDF path is substituted by a Property Node.
 * @author Oliver Fodor (fodor@itc.it)
 */
public class PathBridge extends CNOEntity {

    private String m_strXPath;
    private String m_strOPath;


    public PathBridge(final NormMap normmap, Instance instance) {

        super( normmap, instance );
    }


    public PathBridge( final NormMap normmap, String strURI ) throws KAONException {

        super( normmap, KAONUtils.addConceptInstanceToOIModel( normmap.m_oimodelCNOInstance,
                                                  CNOVocabulary.URI_CNO_PATH_BRIDGE,
                                                  strURI) );
    }

/*
----------------------------------- parsing methods --------------------------------------------
*/


    public void parse() throws Exception {

        super.parse();

	m_strXPath = Parsing.readEventualPropertyLiteral(m_instance, CNOVocabulary.URI_CNO_RELATES_XPATH, CNOErrors.ERROR_ONE_AND_ONLY_ONE_CONCEPT_SOURCE_ENTITY);

	m_strOPath = Parsing.readEventualPropertyValue(m_instance, CNOVocabulary.URI_CNO_RELATES_RDFSPATH, CNOErrors.ERROR_ONE_AND_ONLY_ONE_CONCEPT_TARGET_ENTITY);
    }

/*
----------------------------------- getters & setters --------------------------------------------
*/

    public String getRelatedOPath() {

        return m_strOPath;
    }

    public String getRelatedOPathObject() {

        return m_normmap.getPropertyNode(m_strOPath).getURIObject();
    }

    public String getRelatedOPathProperty() {

        return m_normmap.getPropertyNode(m_strOPath).getURIProperty();
    }

    public String getRelatedXPath() {

        return m_strXPath;
    }

    public void setRelatedXPath( String xpath ) throws NormalisationException {

        if( m_strXPath != null && !m_strXPath.equals( "" ) )
            throw new NormalisationException( CNOErrors.ERROR_ONE_AND_ONLY_ONE_SOURCE_ENTITY + " in " + toString() );

        addPropertyValueToOIModel( CNOVocabulary.URI_CNO_RELATES_XPATH, xpath );

        m_strXPath = xpath;
    }

    public void setRelatedOPath( String opath ) throws NormalisationException {

        if( m_strOPath != null && !m_strOPath.equals( "" ) )
            throw new NormalisationException( CNOErrors.ERROR_ONE_AND_ONLY_ONE_SOURCE_ENTITY + " in " + toString() );

        addPropertyValueToOIModel( CNOVocabulary.URI_CNO_RELATES_RDFSPATH, opath );

        m_strOPath = opath;
    }

    public Element getXSLTemplate(Document xslDoc) throws NormalisationException {

        try {

            Element currentTNode = xslDoc.createElementNS(CNOVocabulary.URI_XSL, CNOVocabulary.NS_PREFIX_XSL + ":for-each");
            currentTNode.setAttribute("select", m_strXPath);

            Element currentNode;

            if (TransformationUtil.isLiteralXPath(m_strXPath) || TransformationUtil.isAttributeXPath(m_strXPath)) {
                currentNode = TransformationUtil.createAndAppendXSLElement(xslDoc, currentTNode, "element", "name", getRelatedOPathProperty().replaceFirst(m_normmap.getRelatedOntologyURI() + "#", CNOVocabulary.NS_PREFIX_DNORM + ":"));
                currentNode = TransformationUtil.createAndAppendXSLElement(xslDoc, currentNode, "value-of", "select", ".");
            } else {
                currentNode = TransformationUtil.createAndAppendXSLElement(xslDoc, currentTNode, "element", "name", getRelatedOPathProperty().replaceFirst(m_normmap.getRelatedOntologyURI() + "#", CNOVocabulary.NS_PREFIX_DNORM + ":"));
                currentNode = TransformationUtil.createAndAppendXSLElement(xslDoc, currentNode, "attribute", "name", "rdf:resource");
                currentNode = TransformationUtil.createAndAppendXSLElement(xslDoc, currentNode, "value-of", "select", "concat('#',generate-id())");
            }

            return currentTNode;

        } catch (Exception e) {

            e.printStackTrace();
            throw new NormalisationException("Exception reparsing PathBridge to XSLT.", e);

        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -