当前位置: 首页>>代码示例>>Java>>正文


Java XSD类代码示例

本文整理汇总了Java中org.apache.jena.vocabulary.XSD的典型用法代码示例。如果您正苦于以下问题:Java XSD类的具体用法?Java XSD怎么用?Java XSD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XSD类属于org.apache.jena.vocabulary包,在下文中一共展示了XSD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLabelFromBuiltIn

import org.apache.jena.vocabulary.XSD; //导入依赖的package包/类
private String getLabelFromBuiltIn(String uri){
	try {
		IRI iri = IRI.create(URLDecoder.decode(uri, "UTF-8"));
		
		// if IRI is built-in entity
		if(iri.isReservedVocabulary()) {
			// use the short form
			String label = sfp.getShortForm(iri);
			
			 // if it is a XSD numeric data type, we attach "value"
            if(uri.equals(XSD.nonNegativeInteger.getURI()) || uri.equals(XSD.integer.getURI())
            		|| uri.equals(XSD.negativeInteger.getURI()) || uri.equals(XSD.decimal.getURI())
            		|| uri.equals(XSD.xdouble.getURI()) || uri.equals(XSD.xfloat.getURI())
            		|| uri.equals(XSD.xint.getURI()) || uri.equals(XSD.xshort.getURI())
            		|| uri.equals(XSD.xbyte.getURI()) || uri.equals(XSD.xlong.getURI())
            		){
            	label += " value";
            }
            
            return label;
		}
	} catch (UnsupportedEncodingException e) {
		logger.error("Getting short form of " + uri + "failed.", e);
	}
	return null;
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:27,代码来源:DefaultIRIConverter.java

示例2: getLabelFromBuiltIn

import org.apache.jena.vocabulary.XSD; //导入依赖的package包/类
private String getLabelFromBuiltIn(String uri) {
	try {
		IRI iri = IRI.create(URLDecoder.decode(uri, "UTF-8"));

		// if IRI is built-in entity
		if (iri.isReservedVocabulary()) {
			// use the short form
			String label = sfp.getShortForm(iri);

			// if it is a XSD numeric data type, we attach "value"
			if (uri.equals(XSD.nonNegativeInteger.getURI()) || uri.equals(XSD.integer.getURI())
					|| uri.equals(XSD.negativeInteger.getURI()) || uri.equals(XSD.decimal.getURI())
					|| uri.equals(XSD.xdouble.getURI()) || uri.equals(XSD.xfloat.getURI())
					|| uri.equals(XSD.xint.getURI()) || uri.equals(XSD.xshort.getURI())
					|| uri.equals(XSD.xbyte.getURI()) || uri.equals(XSD.xlong.getURI())) {
				label += " value";
			}

			return label;
		}
	} catch (UnsupportedEncodingException e) {
		logger.error("Getting short form of " + uri + "failed.", e);
	}
	return null;
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:26,代码来源:DefaultIRIConverterFrench.java

示例3: parseXsdType

import org.apache.jena.vocabulary.XSD; //导入依赖的package包/类
/**
 * Returns the {@link Datatype} instance fitting the given XSD datatype or
 * {@link Datatype#STRING} if no valid type can be found.
 *
 *
 * @param typeResource
 *            XSD resource
 * @return the datatype for this resource
 */
public static Datatype parseXsdType(Resource typeResource) {
    if (XSD.xstring.equals(typeResource)) {
        return Datatype.STRING;
    } else if (XSD.xboolean.equals(typeResource)) {
        return Datatype.BOOLEAN;
    } else if (XSD.decimal.equals(typeResource)) {
        return Datatype.DECIMAL;
    } else if (XSD.xint.equals(typeResource)) {
        return Datatype.INTEGER;
    } else if (XSD.unsignedInt.equals(typeResource) || XSD.positiveInteger.equals(typeResource)) {
        return Datatype.UNSIGNED_INT;
    } else if (XSD.xdouble.equals(typeResource)) {
        return Datatype.DOUBLE;
    } else if (XSD.xfloat.equals(typeResource)) {
        return Datatype.FLOAT;
    } else {
        LOGGER.warn("Got an unsupported parameter type: {}. It will be handled as String.", typeResource.getURI());
        return Datatype.STRING;
    }
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:30,代码来源:RdfModelHelper.java

示例4: createTyped

import org.apache.jena.vocabulary.XSD; //导入依赖的package包/类
public static final RDFNode createTyped(String value, Resource valueType)
   {
if (value == null) throw new IllegalArgumentException("Param value cannot be null");

       // without value type, return default xsd:string value
       if (valueType == null) return ResourceFactory.createTypedLiteral(value, XSDDatatype.XSDstring);

       // if value type is from XSD namespace, value is treated as typed literal with XSD datatype
       if (valueType.getNameSpace().equals(XSD.getURI()))
       {
           RDFDatatype dataType = NodeFactory.getType(valueType.getURI());
           return ResourceFactory.createTypedLiteral(value, dataType);
       }
       // otherwise, value is treated as URI resource
       else
           return ResourceFactory.createResource(value);
   }
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:18,代码来源:RDFNodeFactory.java

示例5: test_OwlProfile

import org.apache.jena.vocabulary.XSD; //导入依赖的package包/类
@Test
public void test_OwlProfile() {
	OwlProfile owlProfile = new OwlProfile(OwlProfileEnum.OWL1_Lite);
	
	assertFalse(owlProfile.isOwl2());		
	assertFalse(owlProfile.supportsStatement(OWL.complementOf, null));
	assertFalse(owlProfile.supportsStatement(OWL2.hasKey, null));
	assertFalse(owlProfile.supportsStatement(OWL.oneOf, null));
	assertFalse(owlProfile.supportsStatement(OWL.unionOf, null));		
	
	assertFalse(owlProfile.supportsStatement(OWL.disjointWith, uri1));
	assertFalse(owlProfile.supportsStatement(OWL.disjointWith, uriList));
	
	assertTrue(owlProfile.supportsStatement(RDF.type, null));
	
	assertTrue(owlProfile.supportDataType(XSD.xstring));
	assertTrue(owlProfile.supportDataType(XSD.integer));
	assertTrue(owlProfile.supportDataType(XSD.decimal));
	assertTrue(owlProfile.supportDataType(XSD.dateTime));
	assertTrue(owlProfile.supportDataType(XSD.xdouble));
	assertTrue(owlProfile.supportDataType(XSD.xboolean));
	
	assertFalse(owlProfile.supportDataType(RdfVocabulary.OWL.real));	
}
 
开发者ID:Web-of-Building-Data,项目名称:drumbeat-ifc2ld,代码行数:25,代码来源:Test_OwlProfile_supportsStatement.java

示例6: test_SupportStatement_Owl1DL

import org.apache.jena.vocabulary.XSD; //导入依赖的package包/类
@Test
public void test_SupportStatement_Owl1DL() {
	OwlProfile owlProfile = new OwlProfile(OwlProfileEnum.OWL1_DL);

	assertFalse(owlProfile.isOwl2());		
	assertTrue(owlProfile.supportsStatement(OWL.complementOf, null));
	assertTrue(owlProfile.supportsStatement(OWL2.hasKey, null));
	assertTrue(owlProfile.supportsStatement(OWL.oneOf, null));
	assertTrue(owlProfile.supportsStatement(OWL.unionOf, null));		
	
	assertTrue(owlProfile.supportsStatement(OWL.disjointWith, uri1));
	assertFalse(owlProfile.supportsStatement(OWL.disjointWith, uriList));
	
	assertTrue(owlProfile.supportsStatement(RDF.type, null));
	
	assertTrue(owlProfile.supportDataType(XSD.xstring));
	assertTrue(owlProfile.supportDataType(XSD.integer));
	assertTrue(owlProfile.supportDataType(XSD.decimal));
	assertTrue(owlProfile.supportDataType(XSD.dateTime));
	assertTrue(owlProfile.supportDataType(XSD.xdouble));
	assertTrue(owlProfile.supportDataType(XSD.xboolean));
	
	assertFalse(owlProfile.supportDataType(RdfVocabulary.OWL.real));		
}
 
开发者ID:Web-of-Building-Data,项目名称:drumbeat-ifc2ld,代码行数:25,代码来源:Test_OwlProfile_supportsStatement.java

示例7: test_SupportStatement_Owl1Full

import org.apache.jena.vocabulary.XSD; //导入依赖的package包/类
@Test
public void test_SupportStatement_Owl1Full() {
	OwlProfile owlProfile = new OwlProfile(OwlProfileEnum.OWL1_Full);
	
	assertFalse(owlProfile.isOwl2());
	assertTrue(owlProfile.supportsStatement(OWL.complementOf, null));
	assertTrue(owlProfile.supportsStatement(OWL2.hasKey, null));
	assertTrue(owlProfile.supportsStatement(OWL.oneOf, null));
	assertTrue(owlProfile.supportsStatement(OWL.unionOf, null));		
	assertTrue(owlProfile.supportsStatement(RDF.type, null));		
	
	assertTrue(owlProfile.supportsStatement(OWL.disjointWith, uri1));
	assertFalse(owlProfile.supportsStatement(OWL.disjointWith, uriList));
	
	assertTrue(owlProfile.supportDataType(XSD.xstring));
	assertTrue(owlProfile.supportDataType(XSD.integer));
	assertTrue(owlProfile.supportDataType(XSD.decimal));
	assertTrue(owlProfile.supportDataType(XSD.dateTime));
	assertTrue(owlProfile.supportDataType(XSD.xdouble));
	assertTrue(owlProfile.supportDataType(XSD.xboolean));
	
	assertFalse(owlProfile.supportDataType(RdfVocabulary.OWL.real));
}
 
开发者ID:Web-of-Building-Data,项目名称:drumbeat-ifc2ld,代码行数:24,代码来源:Test_OwlProfile_supportsStatement.java

示例8: test_SupportStatement_Owl2DL

import org.apache.jena.vocabulary.XSD; //导入依赖的package包/类
@Test
public void test_SupportStatement_Owl2DL() {
	OwlProfile owlProfile = new OwlProfile(OwlProfileEnum.OWL2_DL);

	assertTrue(owlProfile.isOwl2());

	assertTrue(owlProfile.supportsStatement(OWL.complementOf, null));
	assertTrue(owlProfile.supportsStatement(OWL2.hasKey, null));
	assertTrue(owlProfile.supportsStatement(OWL.oneOf, null));
	assertTrue(owlProfile.supportsStatement(OWL.unionOf, null));		
	assertTrue(owlProfile.supportsStatement(RDF.type, null));		
	
	assertTrue(owlProfile.supportsStatement(OWL.disjointWith, uri1));
	assertTrue(owlProfile.supportsStatement(OWL.disjointWith, uriList));
	
	assertTrue(owlProfile.supportDataType(XSD.xstring));
	assertTrue(owlProfile.supportDataType(XSD.integer));
	assertTrue(owlProfile.supportDataType(XSD.decimal));
	assertTrue(owlProfile.supportDataType(XSD.dateTime));

	assertTrue(owlProfile.supportDataType(XSD.xdouble));
	assertTrue(owlProfile.supportDataType(XSD.xboolean));
	assertTrue(owlProfile.supportDataType(RdfVocabulary.OWL.real));
}
 
开发者ID:Web-of-Building-Data,项目名称:drumbeat-ifc2ld,代码行数:25,代码来源:Test_OwlProfile_supportsStatement.java

示例9: getBaseTypeForBooleans

import org.apache.jena.vocabulary.XSD; //导入依赖的package包/类
/**
 * Returns the equivalent XSD datatype for IFC types: BOOLEAN and LOGICAL
 * @return
 */
public Resource getBaseTypeForBooleans() {
	
	if (baseTypeForBooleans == null) {
		String convertBooleanValuesTo = context.getConversionParams().convertBooleansTo();
		switch (convertBooleanValuesTo) {
		case StringParam.VALUE_AUTO:
		case Ifc2RdfConversionParams.VALUE_NAMED_INDIVIDUAL:
			baseTypeForBooleans = OWL2.NamedIndividual;
			break;
		case Ifc2RdfConversionParams.VALUE_XSD_STRING:
			baseTypeForBooleans = XSD.xstring;
			break;
		case Ifc2RdfConversionParams.VALUE_XSD_BOOLEAN:
			baseTypeForBooleans = XSD.xboolean;
			break;
		default:
			throw new IllegalArgumentException("Invalid value of option " + Ifc2RdfConversionParams.PARAM_CONVERT_BOOLEANS_TO);
		}
	}
	return baseTypeForBooleans;		
}
 
开发者ID:Web-of-Building-Data,项目名称:drumbeat-ifc2ld,代码行数:26,代码来源:Ifc2RdfExporterBase.java

示例10: getBaseTypeForEnums

import org.apache.jena.vocabulary.XSD; //导入依赖的package包/类
/**
 * Returns the equivalent XSD datatype for IFC types: ENUM and LOGICAL
 * @return
 */
private Resource getBaseTypeForEnums() {
	
	if (baseTypeForEnums == null) {
		String convertEnumValuesTo = (String)context.getConversionParams().getParamValue(Ifc2RdfConversionParams.PARAM_CONVERT_ENUMS_TO);
		switch (convertEnumValuesTo) {
		case StringParam.VALUE_AUTO:
		case Ifc2RdfConversionParams.VALUE_NAMED_INDIVIDUAL:
			baseTypeForEnums = OWL2.NamedIndividual;
			break;
		case Ifc2RdfConversionParams.VALUE_XSD_STRING:
			baseTypeForEnums = XSD.xstring;
			break;
		default:
			throw new IllegalArgumentException("Invalid value of option " + Ifc2RdfConversionParams.PARAM_CONVERT_ENUMS_TO);
		}
	}
	return baseTypeForEnums;
	
}
 
开发者ID:Web-of-Building-Data,项目名称:drumbeat-ifc2ld,代码行数:24,代码来源:Ifc2RdfExporterBase.java

示例11: setNsPrefixes

import org.apache.jena.vocabulary.XSD; //导入依赖的package包/类
public static void setNsPrefixes(Model jenaModel, Ifc2RdfConverter converter) {
	// define owl:
	jenaModel.setNsPrefix(RdfVocabulary.OWL.BASE_PREFIX, OWL.getURI());

	// define rdf:
	jenaModel.setNsPrefix(RdfVocabulary.RDF.BASE_PREFIX, RDF.getURI());

	// define rdfs:
	jenaModel.setNsPrefix(RdfVocabulary.RDFS.BASE_PREFIX, RDFS.getURI());

	// define xsd:
	jenaModel.setNsPrefix(RdfVocabulary.XSD.BASE_PREFIX, XSD.getURI());

	// define expr:
	jenaModel.setNsPrefix(Ifc2RdfVocabulary.EXPRESS.BASE_PREFIX,
			Ifc2RdfVocabulary.EXPRESS.getBaseUri());

	// define ifc:
	if (converter != null) {
		jenaModel.setNsPrefix(Ifc2RdfVocabulary.IFC.BASE_PREFIX,
				converter.getIfcOntologyNamespaceUri());
	}
}
 
开发者ID:Web-of-Building-Data,项目名称:drumbeat-ifc2ld,代码行数:24,代码来源:DrumbeatTestHelper.java

示例12: toXMLText

import org.apache.jena.vocabulary.XSD; //导入依赖的package包/类
public boolean toXMLText(Element element, RDFNode rdf, String type, String pack, Context ctx) {
	String v;
	Document doc = element.getOwnerDocument();
	
	simpleType s = ctx.getSimpleType(type);
	if (s!=null) return s.toXML(element,rdf,pack,ctx);

	if (type!=null && type.equals(XSD_URI+"#IDREFS") && rdf instanceof Resource
			&& ((Resource)rdf).hasProperty(RDF.first)
			&& rdf.canAs(RDFList.class)) {
		RDFList l = (RDFList) rdf.as(RDFList.class);
		for (ExtendedIterator i=l.iterator(); i.hasNext();) {
			v = toXMLValue(element, (RDFNode) i.next(), XSD.IDREF.getURI(), ctx);
			if (v==null) return false; // failed for this type
			element.appendChild(doc.createTextNode(pack==null?v:pack+v));
			pack = " ";
		}
		return true;
	}
	String val = toXMLValue(element, rdf, type, ctx);
	if (val!=null) {
		element.appendChild(doc.createTextNode(pack==null?val:pack+val));
		return true;
	}
	return false;
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:27,代码来源:schema.java

示例13: toXML

import org.apache.jena.vocabulary.XSD; //导入依赖的package包/类
private void toXML(Element e, Context ctx, attribute def, String type, RDFNode object) 
throws Exception {
	Document doc = e.getOwnerDocument();
	schema xs = (schema) this.get_owner();
	Attr a;
	if (isQualified()) {
		String ns = xs.getTargetNamespace();
		a = doc.createAttributeNS(ns, def.getName());
		//if (Character.isLetterOrDigit(ns.charAt(ns.length()-1))) ns += "#";
		a.setPrefix(ctx.getModel().getNsURIPrefix(ns));
		e.setAttributeNodeNS(a);
	}
	else e.setAttributeNode(a = doc.createAttribute(def.getName()));

	XMLBean t = get_type(ctx);
	if (t instanceof simpleType) ((simpleType) t).toXML(a,object,ctx);
	else if (type != null && type.endsWith("IDREFS"))
		xs.listToXML(a,(RDFList) object.as(RDFList.class),XSD.IDREF.getURI(),ctx);
	else a.setValue(xs.toXMLValue(e,object,type,ctx));
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:21,代码来源:attribute.java

示例14: getTimeUnits

import org.apache.jena.vocabulary.XSD; //导入依赖的package包/类
static private List<TimeUnit> getTimeUnits(Cube cube)
{
	List<TimeUnit> timeUnits = cubeToTimeUnits.get(cube);
	if(timeUnits==null)
	{
		synchronized(cube)
		{
			if(timeUnits==null) {
				timeUnits = Arrays.asList(
						new TimeUnit(cube,"day",XSD.gDay),
						new TimeUnit(cube,"day",XSD.date),
						new TimeUnit(cube,"month",XSD.gMonth),
						new TimeUnit(cube,"year",XSD.gYear)
						).stream().filter(tu->tu.property.isPresent()).collect(Collectors.toList());
				cubeToTimeUnits.put(cube, timeUnits);
			}
		}
	}
	return timeUnits;
}
 
开发者ID:AskNowQA,项目名称:cubeqa,代码行数:21,代码来源:PerTimeDetector.java

示例15: match

import org.apache.jena.vocabulary.XSD; //导入依赖的package包/类
/** How probably is the phrase referring to this property? */
public double match(final String phrase)
{
	String noStop = Stopwords.remove(phrase, Stopwords.PROPERTY_WORDS).toLowerCase();
	OptionalDouble pLabelOpt = labels.stream().mapToDouble(l->Similarity.similarity(Stopwords.remove(l,Stopwords.PROPERTY_WORDS).toLowerCase(),noStop)).max();
	double pLabel = pLabelOpt.isPresent()?pLabelOpt.getAsDouble():0;
	log.trace("p label for "+noStop+": "+pLabel);
	if(phrase.contains("agencies"))
	{
		System.out.println(phrase+": "+this.labels+" "+pLabel);
	}

	OptionalDouble pRangeOpt = MATCH_RANGE? rangeLabels.stream().mapToDouble(l->Similarity.similarity(l,noStop)).max():OptionalDouble.of(0);
	// we only want objectproperties, so exclude xsd
	double pRange = (pRangeOpt.isPresent()&&!range.startsWith(XSD.getURI()))?pRangeOpt.getAsDouble()*RANGE_LABEL_MULTIPLIER:0;
	log.trace("p range for "+noStop+": "+pRange);
	return Math.max(pLabel, pRange);
}
 
开发者ID:AskNowQA,项目名称:cubeqa,代码行数:19,代码来源:ComponentProperty.java


注:本文中的org.apache.jena.vocabulary.XSD类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。