Here you can find the source of extractBaseUriFromRDF(String rdfString)
null
otherwise.
Parameter | Description |
---|---|
rdfString | RDF/XML-serialization to parse |
Parameter | Description |
---|---|
URISyntaxException | an exception |
public static URI extractBaseUriFromRDF(String rdfString) throws URISyntaxException
//package com.java2s; /*// www .j av a 2 s . c o m * SWS Challenge 2008 * * You can redistribute this program and/or modify it under the terms * of the GNU General Public License version 3 (GPL v3.0). * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * You should have received a copy of the GPL * along with this program; if not, please have a look at * http://www.gnu.org/licenses/gpl.html * to obtain the full license text. * * Author of this program: * Ralf Weinand * Nils Barnickel * Fraunhofer Institute FOKUS, http://www.fokus.fraunhofer.de * */ import java.net.URI; import java.net.URISyntaxException; public class Main { /** * Parses a RDF/XML-serialization and returns the base-URI if a value for * 'xml:base' was set, <code>null</code> otherwise. * * @param rdfString * RDF/XML-serialization to parse * @return the base-URI * @throws URISyntaxException */ public static URI extractBaseUriFromRDF(String rdfString) throws URISyntaxException { int startPos = -1; int endPos = -1; startPos = rdfString.indexOf("xml:base=\"") + 10; if (startPos > 10) { endPos = rdfString.indexOf("\"", startPos + 1); } else { startPos = rdfString.indexOf("xmlns=\"") + 7; endPos = rdfString.indexOf("\"", startPos + 1) - 1; // -1 because // protege puts // a '#' after // xml:base-declaration } String uri = rdfString.substring(startPos, endPos); return new URI(uri); } }