Example #1
0
        public void writerWritesRdfNodeIdForBlankNodeObject()
        {
            XmlWriterStore xmlWriter = new XmlWriterStore();
            RdfXmlWriter   rdfWriter = new RdfXmlWriter(xmlWriter);

            writeSingleUUBTriple(rdfWriter);

            Assert.IsTrue(xmlWriter.WasWriteStartAttributeCalledWith("rdf", "nodeID", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"), "start attribute");
            Assert.IsTrue(xmlWriter.WasWriteStringCalledWith("genid1"), "attribute content");
        }
Example #2
0
        public void writerWritesRdfResourceForUriRefObject()
        {
            XmlWriterStore xmlWriter = new XmlWriterStore();
            RdfXmlWriter   rdfWriter = new RdfXmlWriter(xmlWriter);

            writeSingleUUUTriple(rdfWriter);

            Assert.IsTrue(xmlWriter.WasWriteStartAttributeCalledWith("rdf", "resource", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"), "start attribute");
            Assert.IsTrue(xmlWriter.WasWriteStringCalledWith("http://example.com/obj"), "attribute content");
        }
Example #3
0
        public void rdfNamespacePrefixCanBeChanged()
        {
            XmlWriterStore xmlWriter = new XmlWriterStore();
            RdfXmlWriter   rdfWriter = new RdfXmlWriter(xmlWriter);

            rdfWriter.RegisterNamespacePrefix("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "wtf");

            rdfWriter.StartOutput();
            rdfWriter.StartSubject();
            rdfWriter.WriteUriRef("http://example.com/subj");
            rdfWriter.StartPredicate();
            rdfWriter.WriteUriRef("http://foo.example.com/name");
            rdfWriter.StartObject();
            rdfWriter.WriteUriRef("http://example.com/obj");
            rdfWriter.EndObject();
            rdfWriter.EndPredicate();
            rdfWriter.EndSubject();
            rdfWriter.EndOutput();

            Assert.IsTrue(xmlWriter.WasWriteStartElementCalledWith("wtf", "RDF", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"), "RDF element uses registered prefix");
            Assert.IsTrue(xmlWriter.WasWriteStartElementCalledWith("wtf", "Description", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"), "Description element uses registered prefix");
            Assert.IsTrue(xmlWriter.WasWriteStartAttributeCalledWith("wtf", "about", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"), "about attribute uses registered prefix");
            Assert.IsTrue(xmlWriter.WasWriteStartAttributeCalledWith("wtf", "resource", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"), "resource attribute uses registered prefix");
        }