---
name: "RDF::Redland::Parser"
section: "3pm"
platform: "linux"
package: "librdf-perl"
version: "1.0.17.1+dfsg-6+b6"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/RDF::Redland::Parser"
---

# RDF::Redland::Parser(3pm)

Redland RDF Syntax Parsers Class

## NAME

RDF::Redland::Parser - Redland RDF Syntax Parsers Class

## SYNOPSIS

```
  use RDF::Redland;
  ...
  my $parser=new RDF::Redland::Parser("rdfxml");
  my $parser2=new RDF::Redland::Parser(undef, "application/rdf+xml);
  # Return as an RDF::Redland::Stream
  my $stream=$parser->parse_as_stream($source_uri, $base_uri);

  # Store in an RDF::Redland::Model
  $parser->parse_into_model($source_uri, $base_uri, $model);
```

## DESCRIPTION

This class represents parsers of various syntaxes that can deliver a RDF model either as a RDF::Redland::Stream of RDF::Redland::Statement objects or directly into an RDF::Redland::Model object.

## CONSTRUCTORS

- new \[NAME \[MIME\_TYPE \[URI\]\]\]

  Create a new RDF::Redland::Parser object for a syntax parser named *NAME*, with MIME Type *MIME\_TYPE* and/or URI *URI*.  Any field can be undef or omitted; if all are omitted, a parser that provides MIME Type  application/rdf+xml will be requested.

## METHODS

- parse\_as\_stream SOURCE\_URI BASE\_URI

  Parse the syntax at the RDF::Redland::URI *SOURCE\_URI* with optional base RDF::Redland::URI *BASE\_URI*.  If the base URI is given then the content is parsed as if it was at the base URI rather than the source URI.

  Returns an RDF::Redland::Stream of RDF::Redland::Statement objects or undef on failure.

- parse\_into\_model SOURCE\_URI BASE\_URI MODEL \[HANDLER\]

  Parse the syntax at the RDF::Redland::URI *SOURCE\_URI* with optional base RDF::Redland::URI *BASE\_URI* into RDF::Redland::Model *MODEL*.  If the base URI is given then the content is parsed as if it was at the base URI rather than the source URI.

  If the optional *HANDLER* is given, it is a reference to a sub with the signature\
     sub handler($$$$$$$$$) {\
       my($code, `$level`, `$facility`, `$message`, `$line`, `$column`, `$byte`, `$file`, `$uri`)=@\_;\
       ...\
     } that receives errors in parsing.

- parse\_string\_as\_stream STRING BASE\_URI

  Parse the syntax in *STRING* with required base RDF::Redland::URI *BASE\_URI*.

  Returns an RDF::Redland::Stream of RDF::Redland::Statement objects or undef on failure.

- parse\_string\_into\_model STRING BASE\_URI MODEL \[HANDLER\]

  Parse the syntax in *STRING* with required base RDF::Redland::URI *BASE\_URI* into RDF::Redfland::Model *MODEL*.

  If the optional *HANDLER* is given, it is a reference to a sub with the signature\
     sub handler($$$$$$$$$) {\
       my($code, `$level`, `$facility`, `$message`, `$line`, `$column`, `$byte`, `$file`, `$uri`)=@\_;\
       ...\
     } that receives errors in parsing.

- feature URI \[VALUE\]

  Get/set a parser feature.  The feature is named via RDF::Redland::URI *URI* and the value is a RDF::Redland::Node.  If *VALUE* is given, the feature is set to that value, otherwise the current value is returned.

- namespaces\_seen

  Get the set of namespace declarations seen during parsing as a hash of key:prefix string (may be ''), value: RDF::Redland::URI objects.

## SEE ALSO

RDF::Redland::URI

## AUTHOR

Dave Beckett - http://www.dajobe.org/
