Jena multiple rdfs:label - java
I'm new to Jena and Owl I was given an ontology. I can open it with Protege 4.2 without any problems but when I try to open it with Jena I get:
Exception in thread "main" org.apache.jena.riot.RiotException: {E201} Multiple children of property element.
I have been looking a bit in my Ontology what it could be and I have noticed that some elements have more than one Label in a language for example:
<AnnotationAssertion>
<AnnotationProperty abbreviatedIRI="rdfs:label"/>
<AbbreviatedIRI>atc:A02BX02</AbbreviatedIRI>
<Literal xml:lang="no" datatypeIRI="&rdf;PlainLiteral">Sukralfat</Literal>
</AnnotationAssertion>
<AnnotationAssertion>
<AnnotationProperty abbreviatedIRI="rdfs:label"/>
<AbbreviatedIRI>atc:A02BX02</AbbreviatedIRI>
<Literal xml:lang="no" datatypeIRI="&rdf;PlainLiteral">antepsin</Literal>
</AnnotationAssertion>
<AnnotationAssertion>
<AnnotationProperty abbreviatedIRI="rdfs:label"/>
<AbbreviatedIRI>atc:A02BX02</AbbreviatedIRI>
<Literal datatypeIRI="&xsd;string">sucralfate</Literal>
</AnnotationAssertion>
<AnnotationAssertion>
<AnnotationProperty abbreviatedIRI="rdfs:label"/>
<AbbreviatedIRI>atc:A02BX02</AbbreviatedIRI>
<Literal xml:lang="no" datatypeIRI="&rdf;PlainLiteral">sukralfat</Literal>
</AnnotationAssertion>
Could this cause the problem? All the code I use works with other ontologies so I think it really comes from this ontology.
Do you know what could cause this exception?
Edit
So I got down to a minimized case and still get the same error:
<?xml version="1.0"?>
<!DOCTYPE Ontology [
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY xml "http://www.w3.org/XML/1998/namespace" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
<Ontology xmlns="http://www.w3.org/2002/07/owl#"
xml:base="http://www.ebi.ac.uk/Rebholz-srv/atc/public/ontologies/atc.owl"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
ontologyIRI="http://www.ebi.ac.uk/Rebholz-srv/atc/public/ontologies/atc.owl">
<Prefix name="" IRI="http://www.ebi.ac.uk/Rebholz-srv/atc/public/ontologies/atc.owl#"/>
<Prefix name="atc" IRI="http://www.legemiddelverket.no/Legemiddelsoek/Sider/Default.aspx#"/>
<Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
<Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
<Prefix name="xml" IRI="http://www.w3.org/XML/1998/namespace"/>
<Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/>
<Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/>
<Declaration>
<Class abbreviatedIRI="atc:J"/>
</Declaration>
<AnnotationAssertion>
<AnnotationProperty abbreviatedIRI="rdfs:label"/>
<AbbreviatedIRI>atc:J</AbbreviatedIRI>
<Literal datatypeIRI="&xsd;string">ANTIINFECTIVES FOR SYSTEMIC USE</Literal>
</AnnotationAssertion>
</Ontology>
Here is the java code:
InputStream in = FileManager.get().open(filename);
if (in == null) {
throw new IllegalArgumentException("File: " + filename + " not found");
}
model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
model.read(in, null);
try {
in.close();
} catch (IOException e) {
System.err.println("Couldn't close the inputStream");
}
Does this help? I really don't have any idea anymore...
That's an OWL2 XML formatted file. Jena does't support that format, but it does support OWL in RDF/XML.
In other words it's expecting the wrong flavour of XML and getting confused.
Try saving it in another format.
Related
Inlining SVG's not working on Unix Server but External SVG's ok
We are using Apache FOP to generate PDF's & have an issue with SVG's. To include an SVG we're using something like the following... <fo:block> <fo:external-graphic src="classpath:image/MyImage.svg" content-width="150mm"/> </fo:block> The above works fine in all environments. Now I'm trying to inline an SVG in the Stylesheet, like this... <fo:block> <fo:instream-foreign-object content-width="272.6mm"> <svg xmlns="http://www.w3.org/2000/svg" width="780" height="120" viewBox="0 0 780 120"> <g style="fill-opacity:0;stroke-width:2;stroke:black"> <rect x="2" y="2" width="254" height="99"/> <rect x="256" y="2" width="485" height="99"/> </g> </svg> </fo:instream-foreign-object> </fo:block> That works OK under Windows, but when deployed on our Linux Server, seems to do nothing. I have read some comments on the Apache FOP Website about it using Apache Batik to render SVG's and that this requires a Graphical Environment, so will not work in many Unix configurations. What I don't understand is, how come the external SVG is working ok on the Unix Server & inline is not? Also, they recommend a Tool called PJA toolkit to workaround this issue, but it looks very dated, so I wonder if its going to work with our JDK 17. I would be grateful if anyone has some Info about this.
Previously we hadn't noticed the symptom, which was a spurious empty Namespace entry on the <g> Element, meaning it no longer belonged to the SVG Namespace: <svg xmlns="http://www.w3.org/2000/svg" height="775" viewBox="0 0 1184 775" width="1184"> <g xmlns="" style="fill-opacity:0;stroke-width:7;stroke:red"> The problem turned out to be Namespace Awareness when parsing the Stylesheet. When enabled, the generated inline SVG works fine. Here's a Java Source to illustrate the Solution. (it uses Multiline Strings which require JDK >= 14) Just look for the TODO & (un)comment that line to see the difference: import java.io.*; import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.*; import org.w3c.dom.Document; import org.xml.sax.SAXException; public class SvgNamespaceDomSimple { private static final String DATA_XML = """ <?xml version="1.0" encoding="UTF-8"?><dataXml/>"""; private static final String STYLESHEET = """ <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="3.0"> <xsl:template match="/"> <fo:root> <fo:layout-master-set> <fo:simple-page-master master-name="singlePage" page-width="297mm" page-height="210mm"> <fo:region-body margin-left="2.19mm" margin-top="6.75mm"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="singlePage"> <fo:flow flow-name="xsl-region-body"> <fo:block> <fo:instream-foreign-object content-width="272.6mm" content-type="image/svg+xml"> <svg xmlns="http://www.w3.org/2000/svg" width="1184" height="775" viewBox="0 0 1184 775"> <g style="fill-opacity:0;stroke-width:7;stroke:black"> <rect width="254" height="99"/> </g> </svg> </fo:instream-foreign-object> </fo:block> </fo:flow> </fo:page-sequence> </fo:root> </xsl:template> </xsl:stylesheet> """; private static Document parse(final byte[] byteArray) throws ParserConfigurationException, SAXException, IOException { final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); ; dbf.setNamespaceAware(true); // TODO setNamespaceAware(true) final DocumentBuilder dbd = dbf.newDocumentBuilder(); final Document doc = dbd.parse(new ByteArrayInputStream(byteArray)); System.out.println("DocumentBuilderFactory.: " + dbf.getClass()); System.out.println("DocumentBuilder........: " + dbd.getClass()); System.out.println("Document...............: " + doc.getClass()); return doc; } public static void main(final String[] args) throws Exception { System .out.println("Data XML...............:" + '\n' + DATA_XML + '\n'); System .out.println("Stylesheet.............:" + '\n' + STYLESHEET); try(final ByteArrayInputStream ist = new ByteArrayInputStream (DATA_XML.getBytes()); final ByteArrayOutputStream ost = new ByteArrayOutputStream();) { final Document stylesheetDoc = parse(STYLESHEET.getBytes()); final TransformerFactory transformerFactory = TransformerFactory.newInstance(); final Templates templates = transformerFactory.newTemplates(new DOMSource(stylesheetDoc)); final Transformer transformer = templates.newTransformer(); transformer.transform(new StreamSource(ist), new StreamResult(ost)); final String foString = new String(ost.toByteArray()); System.out.println("TransformerFactory.....: " + transformerFactory.getClass()); System.out.println("FO Bytes...............:" + '\n' + foString); System.out.println( foString.replace(">", ">" + '\n')); } } } The resulting inline SVG then looked something like this & was rendered fine both under Windows & on our Linux Server: <fo:instream-foreign-object content-width="272.6mm" content-type="image/svg+xml"> <svg xmlns="http://www.w3.org/2000/svg" width="1184" height="775" viewBox="0 0 1184 775"> <g style="fill-opacity:0;stroke-width:7;stroke:black"> <rect width="254" height="99"/> </g> </svg> </fo:instream-foreign-object> As a workaround, you can specify the Namespace explicitly as follows: <fo:instream-foreign-object content-width="272.6mm" content-type="image/svg+xml"> <svg:svg xmlns:svg="http://www.w3.org/2000/svg" width="1184" height="775" viewBox="0 0 1184 775"> <svg:g style="fill-opacity:0;stroke-width:2;stroke:black"> <svg:rect width="254" height="99"/> </svg:g> </svg:svg> </fo:instream-foreign-object>
How to export Weka model made in Java to PMML format
Is there a way i can export a LinearRegression model ( build on some dataset) into a PMML format in Java? The code so far DataSource source = new DataSource("house.arff"); Instances dataset = source.getDataSet(); Instances m_structure = new Instances(dataset, 0); m_structure.setClassIndex(dataset.numAttributes()-1); dataset.setClassIndex(dataset.numAttributes()-1); LinearRegression lReg = new LinearRegression(); int m_NumClasses = dataset.numClasses(); int class_index= dataset.classIndex(); int nK = m_NumClasses - 1; int nR = dataset.numAttributes() - 1; double[][] m_Par = new double[nR + 1][nK]; String pmmlx= LogisticProducerHelper.toPMML(dataset,m_structure,m_Par,m_NumClasses); System.out.println(pmmlx); This produces the following PMML file <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <PMML version="4.1" xmlns="http://www.dmg.org/PMML-4_1"> <Header copyright="WEKA"> <Application name="WEKA" version="3.8.0"/> </Header> <DataDictionary> <DataField name="houseSize" optype="continuous"/> <DataField name="lotSize" optype="continuous"/> <DataField name="bedrooms" optype="continuous"/> <DataField name="granite" optype="continuous"/> <DataField name="bathroom" optype="continuous"/> <DataField name="sellingPrice" optype="continuous"/> </DataDictionary> <RegressionModel algorithmName="logisticRegression" functionName="classification" modelType="logisticRegression" normalizationMethod="softmax"> <MiningSchema> <MiningField missingValueReplacement="3132.0" missingValueTreatment="asMean" name="houseSize" usageType="active"/> <MiningField missingValueReplacement="11788.142857142857" missingValueTreatment="asMean" name="lotSize" usageType="active"/> <MiningField missingValueReplacement="5.0" missingValueTreatment="asMean" name="bedrooms" usageType="active"/> <MiningField missingValueReplacement="0.42857142857142855" missingValueTreatment="asMean" name="granite" usageType="active"/> <MiningField missingValueReplacement="0.7142857142857143" missingValueTreatment="asMean" name="bathroom" usageType="active"/> <MiningField name="sellingPrice" usageType="predicted"/> </MiningSchema> <Output/> </RegressionModel> </PMML> The PMML file above cannot be used to predict an Instance because the model is not yet built. Using the following line builds the Classifier. lReg.buildClassifier(dataset); So I am wondering is there a way that I can add the parameters learned by this classifier into the PMML file so it can be exported/imported easily as a already trained classifier?
According to JavaDoc of LogisticProducerHelper: Helper class for producing PMML for a Logistic classifier. Not designed to be used directly - you should call toPMML() on a trained Logistic classifier. JavaDoc states that only Logistic classifier implements PMMLProducer. If you use Logistic you can use logistic.toPMML(train) method.
VTD-XML reading gives no results
I am trying to read a RSS content using VTD-XML. Below is a sample of RSS. <?xml version="1.0" encoding="UTF-8"?> <rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> <?xml-stylesheet type="text/xsl" href="rss.xsl"?> <channel> <title>MyRSS</title> <atom:link href="http://www.example.com/rss.php" rel="self" type="application/rss+xml" /> <link>http://www.example.com/rss.php</link> <description>MyRSS</description> <language>en-us</language> <pubDate>Tue, 22 May 2018 13:15:15 +0530</pubDate> <item> <title>Title 1</title> <pubDate>Tue, 22 May 2018 13:14:40 +0530</pubDate> <link>http://www.example.com/news.php?nid=47610</link> <guid>http://www.example.com/news.php?nid=47610</guid> <description>bla bla bla</description> </item> </channel> </rss> Anyway as you know, some RSS feeds can contain more styling info etc. However in every RSS, the <channel> and <item> will be common, at least for the ones I need to use. I tried VTD XML to read this as quickly as possible. Below is the code. VTDGen vg = new VTDGen(); if (vg.parseHttpUrl(appDataBean.getUrl(), true)) { VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); ap.selectXPath("/channel/item"); int result = -1; while ((result = ap.evalXPath()) != -1) { if (vn.matchElement("item")) { do { //do something with the contnets in the item node Log.d("VTD", vn.toString(vn.getText())); } while (vn.toElement(VTDNav.NEXT_SIBLING)); } } } Unfortunately this did not print anything. What am I doing wrong here? Also non of the RSS feeds are very big, so I need to read them in couple of miliseconds. This code is on Android.
Xml validation with xsl
i have been trying to validate xml through xslt for couple of hours. i have following xsl form for xml validation. every time i try to validate xml, i get following warnings below and empty currencyid attributes in xml are ignored and xml validate although its not. Does anyone has an idea why its ignored and validated ? <xsl:variable name="CurrencyCodeList" select="',AED,AFN,ALL,AMD,ANG,AOA,ARS,AUD,AWG,AZN,BAM,BBD,BDT,BGN,BHD,BIF,BMD,BND,BOB,BOV,BRL,BSD,BTN,BWP,BYR,BZD,CAD,CDF,CHE,CHF,CHW,CLF,CLP,CNY,COP,COU,CRC,CUC,CUP,CVE,CZK,DJF,DKK,DOP,DZD,EEK,EGP,ERN,ETB,EUR,FJD,FKP,GBP,GEL,GHS,GIP,GMD,GNF,GTQ,GWP,GYD,HKD,HNL,HRK,HTG,HUF,IDR,ILS,INR,IQD,IRR,ISK,JMD,JOD,JPY,KES,KGS,KHR,KMF,KPW,KRW,KWD,KYD,KZT,LAK,LBP,LKR,LRD,LSL,LTL,LVL,LYD,MAD,MAD,MDL,MGA,MKD,MMK,MNT,MOP,MRO,MUR,MVR,MWK,MXN,MXV,MYR,MZN,NAD,NGN,NIO,NOK,NPR,NZD,OMR,PAB,PEN,PGK,PHP,PKR,PLN,PYG,QAR,RON,RSD,RUB,RWF,SAR,SBD,SCR,SDG,SEK,SGD,SHP,SLL,SOS,SRD,STD,SVC,SYP,SZL,THB,TJS,TMT,TND,TOP,TRY,TTD,TWD,TZS,UAH,UGX,USD,USN,USS,UYI,UYU,UZS,VEF,VND,VUV,WST,XAF,XAG,XAU,XBA,XBB,XBC,XBD,XCD,XDR,XFU,XOF,XPD,XPF,XPF,XPF,XPT,XTS,XXX,YER,ZAR,ZMK,ZWL,'"/> <xsl:template match="//#currencyID" priority="1008" mode="M0"> <svrl:fired-rule xmlns:svrl="http://purl.oclc.org/dsdl/svrl" context="//#currencyID"/> <!--ASSERT --> <xsl:choose> <xsl:when test="contains($CurrencyCodeList, concat(',',.,','))"/> <xsl:otherwise> <svrl:failed-assert xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="contains($CurrencyCodeList, concat(',',.,','))"> <xsl:attribute name="location"> <xsl:apply-templates select="." mode="schematron-select-full-path"/> </xsl:attribute> <svrl:text>Geçersiz currencyID niteliği : '<xsl:text/> <xsl:value-of select="."/> <xsl:text/>'. Geçerli değerler için kod listesine bakınız.</svrl:text> </svrl:failed-assert> </xsl:otherwise> </xsl:choose> <xsl:apply-templates select="*|comment()|processing-instruction()" mode="M0"/> Warning: on line 286 The preceding-sibling axis starting at a namespace node will never select anything Warning: on line 311 The preceding-sibling axis starting at a namespace node will never select anything Warning: on line 407 The child axis starting at an attribute node will never select anything Warning: on line 407 The child axis starting at an attribute node will never select anything Warning: on line 407 The child axis starting at an attribute node will never select anything Warning: on line 436 The child axis starting at an attribute node will never select anything Warning: on line 436 The child axis starting at an attribute node will never select anything Warning: on line 436 EDIT: actually i transformed schematron to xslt in order to test it also in xslt. given was schematron for validating. so actually i have to validate through given schematron files, sample xml and java code for validating. main schematron and other files have more rules and patterns. but i removed most of them for sample code and easily testing. everything is validated successfully except attributes in elements.( e.g currencyId attribute). im using UgliSch (Ugli Schematron Validator) for schematron validation. MainSchematron.xml: <?xml version="1.0" encoding="UTF-8"?> <sch:schema xmlns="http://purl.oclc.org/dsdl/schematron" xmlns:sch="http://purl.oclc.org/dsdl/schematron" xmlns:sh="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader" xmlns:ef="http://www.efatura.gov.tr/envelope-namespace"> <sch:include href="UBL-TR_Codelist.xml#codes"/> <sch:include href="UBL-TR_Common_Schematron.xml#abstracts"/> <sch:ns prefix="cbc" uri="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" /> <sch:rule context="//cbc:CurrencyCode"> <sch:extends rule="GeneralCurrencyCodeCheck"/> </sch:rule> <sch:rule context="//#currencyID"> <sch:extends rule="GeneralCurrencyIDCheck"/> </sch:rule> </sch:schema> UBL-TR_Common_Schematron.xml: <sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" xmlns="http://purl.oclc.org/dsdl/schematron"> <sch:pattern name="AbstractRules" id="abstracts"> <sch:p>Pattern for storing abstract rules</sch:p> <!-- Rule to validate currencyID Genel --> <sch:rule abstract="true" id="GeneralCurrencyIDCheck"> <sch:assert test="contains($CurrencyCodeList, concat(',',.,','))">Geçersiz currencyID niteliği : '<sch:value-of select="."/>'. Geçerli değerler için kod listesine bakınız.</sch:assert> </sch:rule> </sch:pattern> </sch:schema> UBL-TR_Codelist.xml: <sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" xmlns="http://purl.oclc.org/dsdl/schematron"> <sch:pattern name="CodeList" id="codes"> <sch:let name="CurrencyCodeList" value="',AED,AFN,ALL,AMD,ANG,AOA,ARS,AUD,AWG,AZN,BAM,BBD,BDT,BGN,BHD,BIF,BMD,BND,BOB,BOV,BRL,BSD,BTN,BWP,BYR,BZD,CAD,CDF,CHE,CHF,CHW,CLF,CLP,CNY,COP,COU,CRC,CUC,CUP,CVE,CZK,DJF,DKK,DOP,DZD,EEK,EGP,ERN,ETB,EUR,FJD,FKP,GBP,GEL,GHS,GIP,GMD,GNF,GTQ,GWP,GYD,HKD,HNL,HRK,HTG,HUF,IDR,ILS,INR,IQD,IRR,ISK,JMD,JOD,JPY,KES,KGS,KHR,KMF,KPW,KRW,KWD,KYD,KZT,LAK,LBP,LKR,LRD,LSL,LTL,LVL,LYD,MAD,MAD,MDL,MGA,MKD,MMK,MNT,MOP,MRO,MUR,MVR,MWK,MXN,MXV,MYR,MZN,NAD,NGN,NIO,NOK,NPR,NZD,OMR,PAB,PEN,PGK,PHP,PKR,PLN,PYG,QAR,RON,RSD,RUB,RWF,SAR,SBD,SCR,SDG,SEK,SGD,SHP,SLL,SOS,SRD,STD,SVC,SYP,SZL,THB,TJS,TMT,TND,TOP,TRY,TTD,TWD,TZS,UAH,UGX,USD,USN,USS,UYI,UYU,UZS,VEF,VND,VUV,WST,XAF,XAG,XAU,XBA,XBB,XBC,XBD,XCD,XDR,XFU,XOF,XPD,XPF,XPF,XPF,XPT,XTS,XXX,YER,ZAR,ZMK,ZWL,'"/> </sch:pattern> </sch:schema> sample.xml: <sh:StandardBusinessDocument xsi:schemaLocation="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader PackageProxy_1_2.xsd" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:ef="http://www.efatura.gov.tr/package-namespace" xmlns:oa="http://www.openapplications.org/oagis/9" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:sh="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ns9="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:ns11="urn:oasis:names:specification:ubl:schema:xsd:ApplicationResponse-2" xmlns:ns3="http://www.hr-xml.org/3" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <sh:StandardBusinessDocumentHeader> <sh:HeaderVersion>1.0</sh:HeaderVersion> <sh:Sender> <sh:Identifier>urn:mail:defaultgb#xxx.com.tr</sh:Identifier> <sh:ContactInformation> <sh:Contact>xxx Kurumsal Bilgi Sistemleri A.Ş</sh:Contact> <sh:ContactTypeIdentifier>UNVAN</sh:ContactTypeIdentifier> </sh:ContactInformation> <sh:ContactInformation> <sh:Contact>8110120507</sh:Contact> <sh:ContactTypeIdentifier>VKN_TCKN</sh:ContactTypeIdentifier> </sh:ContactInformation> </sh:Sender> <sh:Receiver> <sh:Identifier>urn:mail:defaultpk#xxx.com.tr</sh:Identifier> <sh:ContactInformation> <sh:Contact>KAKAR KURUMSAL BİLGİSİSTEMLERİ LTD.ŞTİ. Test Kullanıcısı</sh:Contact> <sh:ContactTypeIdentifier>UNVAN</sh:ContactTypeIdentifier> </sh:ContactInformation> <sh:ContactInformation> <sh:Contact>4545552073</sh:Contact> <sh:ContactTypeIdentifier>VKN_TCKN</sh:ContactTypeIdentifier> </sh:ContactInformation> </sh:Receiver> <sh:DocumentIdentification> <sh:Standard>UBL-TR</sh:Standard> <sh:TypeVersion>1.2</sh:TypeVersion> <sh:InstanceIdentifier>bb583542-a81a-4b45-87d6-e90596101a41</sh:InstanceIdentifier> <sh:Type>SENDERENVELOPE</sh:Type> <sh:MultipleType>false</sh:MultipleType> <sh:CreationDateAndTime>2016-01-06T16:27:25.759+02:00</sh:CreationDateAndTime> </sh:DocumentIdentification> </sh:StandardBusinessDocumentHeader> <ef:Package> <Elements> <ElementType>INVOICE</ElementType> <ElementCount>1</ElementCount> <ElementList> <ns9:Invoice> <ext:UBLExtensions> <ext:UBLExtension> <ext:ExtensionContent> ... </ext:ExtensionContent> </ext:UBLExtension> </ext:UBLExtensions> <cbc:UBLVersionID>2.1</cbc:UBLVersionID> <cbc:CustomizationID>TR1.2</cbc:CustomizationID> <cbc:ProfileID>TICARIFATURA</cbc:ProfileID> <cbc:ID>PAZ2015000000012</cbc:ID> <cbc:CopyIndicator>false</cbc:CopyIndicator> <cbc:UUID>54b0dad2-e3a7-44ee-848a-cf7977000020</cbc:UUID> <cbc:IssueDate>2016-01-06</cbc:IssueDate> <cbc:InvoiceTypeCode>SATIS</cbc:InvoiceTypeCode> <cbc:DocumentCurrencyCode>TRY</cbc:DocumentCurrencyCode> <cbc:LineCountNumeric>0</cbc:LineCountNumeric> <cac:Signature> <cbc:ID schemeID="VKN_TCKN">8110120507</cbc:ID> <cac:SignatoryParty> <cbc:WebsiteURI>http://www.xxx.com.tr/</cbc:WebsiteURI> <cac:PartyIdentification> <cbc:ID schemeID="VKN">8110120507</cbc:ID> </cac:PartyIdentification> <cac:PartyName> <cbc:Name>xxx Kurumsal Bilgi Sistemleri A.Ş</cbc:Name> </cac:PartyName> <cac:PostalAddress> <cbc:StreetName>Besiktas Teknik Universitesi</cbc:StreetName> <cbc:BuildingNumber>150/1G</cbc:BuildingNumber> <cbc:CitySubdivisionName>Besıktas</cbc:CitySubdivisionName> <cbc:CityName>Istanbul</cbc:CityName> <cbc:PostalZone>06100</cbc:PostalZone> <cac:Country> <cbc:Name>Turkiye</cbc:Name> </cac:Country> </cac:PostalAddress> </cac:SignatoryParty> <cac:DigitalSignatureAttachment> <cac:ExternalReference> <cbc:URI>#Signature</cbc:URI> </cac:ExternalReference> </cac:DigitalSignatureAttachment> </cac:Signature> <cac:AccountingSupplierParty> <cac:Party> <cac:PartyIdentification> <cbc:ID schemeID="VKN">7221130507</cbc:ID> </cac:PartyIdentification> <cac:PartyName> <cbc:Name>KAKAR KURUMSAL LTD.ŞTİ.</cbc:Name> </cac:PartyName> <cac:PostalAddress> <cbc:Room/> <cbc:BuildingName/> <cbc:BuildingNumber/> <cbc:CitySubdivisionName>besiktas</cbc:CitySubdivisionName> <cbc:CityName>istanbul</cbc:CityName> <cbc:PostalZone/> <cac:Country> <cbc:Name>ALMANYA</cbc:Name> </cac:Country> </cac:PostalAddress> <cac:Contact> <cbc:Telephone/> <cbc:Telefax/> <cbc:ElectronicMail/> </cac:Contact> </cac:Party> </cac:AccountingSupplierParty> <cac:AccountingCustomerParty> <cac:Party> <cbc:WebsiteURI/> <cac:PartyIdentification> <cbc:ID schemeID="VKN">2535552073</cbc:ID> </cac:PartyIdentification> <cac:PartyName> <cbc:Name>KAKAR LTD.ŞTİ. Test Kullanıcısı</cbc:Name> </cac:PartyName> <cac:PostalAddress> <cbc:ID/> <cbc:Postbox/> <cbc:Room/> <cbc:StreetName/> <cbc:BlockName/> <cbc:BuildingName/> <cbc:BuildingNumber/> <cbc:CitySubdivisionName>besiktas</cbc:CitySubdivisionName> <cbc:CityName>istanbul</cbc:CityName> <cbc:PostalZone/> <cbc:Region/> <cbc:District/> <cac:Country> <cbc:Name>TÜRKİYE</cbc:Name> </cac:Country> </cac:PostalAddress> <cac:Contact> <cbc:Telephone/> <cbc:Telefax/> <cbc:ElectronicMail/> </cac:Contact> <cac:Person> <cbc:FirstName/> <cbc:FamilyName/> </cac:Person> </cac:Party> </cac:AccountingCustomerParty> <cac:TaxTotal> <cbc:TaxAmount currencyID="TRY">2.16</cbc:TaxAmount> <cac:TaxSubtotal> <cbc:TaxableAmount currencyID="asdasdasdasd">0</cbc:TaxableAmount> <cbc:TaxAmount currencyID="TRY">2.16</cbc:TaxAmount> <cbc:CalculationSequenceNumeric>0</cbc:CalculationSequenceNumeric> <cbc:Percent>18</cbc:Percent> <cac:TaxCategory> <cac:TaxScheme> <cbc:Name>KDV</cbc:Name> <cbc:TaxTypeCode>0015</cbc:TaxTypeCode> </cac:TaxScheme> </cac:TaxCategory> </cac:TaxSubtotal> </cac:TaxTotal> <cac:LegalMonetaryTotal> <cbc:LineExtensionAmount currencyID="TRY">12</cbc:LineExtensionAmount> <cbc:TaxExclusiveAmount currencyID="TRY">12</cbc:TaxExclusiveAmount> <cbc:TaxInclusiveAmount currencyID="TRY">14.16</cbc:TaxInclusiveAmount> <cbc:AllowanceTotalAmount currencyID="TRY">0</cbc:AllowanceTotalAmount> <cbc:PayableAmount currencyID="TRY">14.16</cbc:PayableAmount> </cac:LegalMonetaryTotal> <cac:InvoiceLine> <cbc:ID>1</cbc:ID> <cbc:InvoicedQuantity unitCode="NIU">1</cbc:InvoicedQuantity> <cbc:LineExtensionAmount currencyID="">12</cbc:LineExtensionAmount> <cac:AllowanceCharge> <cbc:ChargeIndicator>false</cbc:ChargeIndicator> <cbc:MultiplierFactorNumeric>0</cbc:MultiplierFactorNumeric> <cbc:Amount currencyID="">0</cbc:Amount> <cbc:BaseAmount currencyID="">0</cbc:BaseAmount> </cac:AllowanceCharge> <cac:TaxTotal> <cbc:TaxAmount currencyID="">2.16</cbc:TaxAmount> <cac:TaxSubtotal> <cbc:TaxableAmount currencyID="">0</cbc:TaxableAmount> <cbc:TaxAmount currencyID="">2.16</cbc:TaxAmount> <cbc:Percent>18</cbc:Percent> <cac:TaxCategory> <cac:TaxScheme> <cbc:Name>KDV</cbc:Name> <cbc:TaxTypeCode>0015</cbc:TaxTypeCode> </cac:TaxScheme> </cac:TaxCategory> </cac:TaxSubtotal> </cac:TaxTotal> <cac:Item> <cbc:Name>asdasd</cbc:Name> </cac:Item> <cac:Price> <cbc:PriceAmount currencyID="TRY">12</cbc:PriceAmount> </cac:Price> </cac:InvoiceLine> </ns9:Invoice> </ElementList> </Elements> </ef:Package> </sh:StandardBusinessDocument> java : try (InputStream ubl = getClass().getResourceAsStream("/schematrons/UBL-TR_Main_Schematron.xml");) { SchemaFactory schemaFactory = SchemaFactory.newInstance(XmlSchemaNsUris.SCHEMATRON_NS_URI); Schema schema = schemaFactory.newSchema(new StreamSource(ubl)); Validator validator = schema.newValidator(); validator.setErrorHandler(validationErrorHandler); validator.validate(new StringSource(new String(binary,"UTF-8"))); } catch (Exception e) { e.printStackTrace(); }
Reading RDF data using Jena failing
The following code is to read a schema and a data file to find rdf.type of colin and Person. However, I am getting the error: Exception in thread "main" org.apache.jena.riot.RiotException: [line: 1, col: 1 ] Content is not allowed in prolog. The code is given below: public void reason(){ String NS = "urn:x-hp:eg/"; String fnameschema = "D://Work//EclipseWorkspace//Jena//data//rdfsDemoSchema.rdf"; String fnameinstance = "D://Work//EclipseWorkspace//Jena//data//rdfsDemoData.rdf"; Model schema = FileManager.get().loadModel(fnameschema); Model data = FileManager.get().loadModel(fnameinstance); InfModel infmodel = ModelFactory.createRDFSModel(schema, data); Resource colin = infmodel.getResource(NS+"colin"); System.out.println("Colin has types"); for (StmtIterator i = infmodel.listStatements(colin, RDF.type, (RDFNode)null); i.hasNext(); ) { Statement s = i.nextStatement(); System.out.println(s); } Resource Person = infmodel.getResource(NS+"Person"); System.out.println("\nPerson has types:"); for (StmtIterator i = infmodel.listStatements(Person, RDF.type, (RDFNode)null); i.hasNext(); ) { Statement s = i.nextStatement(); System.out.println(s); } } The file rdfsDemoData.rdf #prefix eg: <urn:x-hp:eg/> . <Teenager rdf:about="⪚colin"> <mum rdf:resource="⪚rosy" /> <age>13</age> </Teenager> The file rdfsDemoSchema.rdf #prefix eg: <urn:x-hp:eg/> . <rdf:Description rdf:about="⪚mum"> <rdfs:subPropertyOf rdf:resource="⪚parent"/> </rdf:Description> <rdf:Description rdf:about="⪚parent"> <rdfs:range rdf:resource="⪚Person"/> <rdfs:domain rdf:resource="⪚Person"/> </rdf:Description> <rdf:Description rdf:about="⪚age"> <rdfs:range rdf:resource="&xsd;integer" /> </rdf:Description>
Your data is bad syntax. You are mixing Turtle and RDF/XML. RDF/XML does nto have #prefix - it uses XML's namespaces. It looks like you want an XML entity declaration like: <?xml version="1.0"?> <!DOCTYPE rdf:RDF [ <!ENTITY eg "urn:x-hp:eg/" > ]> ...