Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8582403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:16:56+00:00 2026-06-11T21:16:56+00:00

I have written following code for extratcting URIs from a web page with content

  • 0

I have written following code for extratcting URIs from a web page with content type application/rdf-xml for Linked Data application.

public static void test(String url) {
    try {
        Model read = ModelFactory.createDefaultModel().read(url);
        System.out.println("to go");
        StmtIterator si;
        si = read.listStatements();
        System.out.println("to go");
        while(si.hasNext()) {
            Statement s=si.nextStatement();
            Resource r=s.getSubject();
            Property p=s.getPredicate();
            RDFNode o=s.getObject();
            System.out.println(r.getURI());
            System.out.println(p.getURI());
            System.out.println(o.asResource().getURI());
        }
    }
    catch(JenaException | NoSuchElementException c) {}
}

But for the input

<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:ex="http://example.org/stuff/1.0/">
    <rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar"
        dc:title="RDF/XML Syntax Specification (Revised)">
        <ex:editor>
            <rdf:Description ex:fullName="Dave Beckett">
                <ex:homePage rdf:resource="http://purl.org/net/dajobe/" />
            </rdf:Description>
        </ex:editor>
    </rdf:Description>
</rdf:RDF>

The output is :

Subject URI is http://www.w3.org/TR/rdf-syntax-grammar
Predicate  URI is http://example.org/stuff/1.0/editor
Object URI is null
Subject URI is http://www.w3.org/TR/rdf-syntax-grammar
Predicate  URI is http://purl.org/dc/elements/1.1/title
Website is read

I require in the output all the URIs present on that page to build a web crawler for RDF pages.
I require all following links in output:

       http://www.w3.org/TR/rdf-syntax-grammar
       http://example.org/stuff/1.0/editor
       http://purl.org/net/dajobe
       http://example.org/stuff/1.0/fullName
       http://www.w3.org/TR/rdf-syntax-grammar
       http://purl.org/dc/elements/1.1/title
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:17:06+00:00Added an answer on June 11, 2026 at 9:17 pm

    Minor mistake: you mean application/rdf+xml (note the plus).

    Anyway, your problem is very simple:

    catch(JenaException | NoSuchElementException c) {}
    

    Bad! You’re missing the error thrown here, and the output is being truncated:

    System.out.println(o.asResource().getURI());
    

    o isn’t always a resource, and this will break on the triple

    <http://www.w3.org/TR/rdf-syntax-grammar> dc:title "RDF/XML Syntax ..."
    

    so you need to guard against that:

    if (o.isResource()) System.out.println(o.asResource().getURI());
    

    or even more specific:

    if (o.isURIResource()) System.out.println(o.asResource().getURI());
    

    which will skip the null output you see for ex:editor.

    Now write one thousand times I will not swallow exceptions 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written following PHP code: $input=menu=1&type=0&; print $input.<hr>.ereg_replace('/&/', ':::', $input); After running above
I have written the following code: //get the user from the DB var tmpuser
I have written following code to get JSON result from webservice. function SaveUploadedDataInDB(fileName) {
I my application I have written following code in order to extract phone number.
I have written following code to attach gesture recogniser to multiple imageviews. [imageview1 setUserInteractionEnabled:YES];
I am trying my hands on WPF MVVM. I have written following code in
i have written the following code class Program { static void Main(string[] args) {
I have written the following code, CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); report.Load(@C:\Users\XXX\Desktop\Backup1\Project\ReportsFolder\ReportSalesInvoice.rpt); Report works
I have written a following code to get just the file name without extension
I have written the following code choice /m Do you want to add another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.