@@ -14,6 +14,9 @@ use oxrdf::{
1414use scraper:: { ElementRef , Html , node:: Element } ;
1515use tracing:: trace;
1616
17+ use crate :: processor_graph:: { MessageType , ProcessorGraph } ;
18+
19+ pub mod processor_graph;
1720pub mod vocabs;
1821
1922pub fn process (
@@ -139,7 +142,7 @@ pub fn parse(
139142 } ( ) ;
140143
141144 if let Err ( e) = get_err {
142- ProcessorGraph ( processor_graph) . emit ( PGType :: DocumentError , & e. to_string ( ) ) ;
145+ ProcessorGraph ( processor_graph) . emit_message ( MessageType :: DocumentError , & e. to_string ( ) ) ;
143146 }
144147
145148 Ok ( ( ) )
@@ -488,8 +491,8 @@ impl<H: HostLanguage> ResolverData<H> {
488491 self . language = Some ( Rc :: new ( lang) ) ;
489492 }
490493 Err ( e) => {
491- processor_graph. borrow_mut ( ) . emit (
492- PGType :: Warning ,
494+ processor_graph. borrow_mut ( ) . emit_message (
495+ MessageType :: Warning ,
493496 & format ! ( "Invalid language identifier ({lang}): {e}" ) ,
494497 ) ;
495498 }
@@ -635,24 +638,24 @@ impl<'e, 'rp, 'p: 'rp, H: HostLanguage> Resolver<'e, 'rp, 'p, H> {
635638 CurieError :: EmptyCurie
636639 | CurieError :: ExpansionError ( ExpansionError :: MissingDefault ) => { }
637640 CurieError :: InvalidBlankNodeSuffix ( suffix) => {
638- self . processor_graph . borrow_mut ( ) . emit (
639- PGType :: UnresolvedCurie ,
641+ self . processor_graph . borrow_mut ( ) . emit_message (
642+ MessageType :: UnresolvedCurie ,
640643 & format ! (
641644 "Invalid CURIE: {value} (invalid blank node suffix: `{suffix}`)" ,
642645 ) ,
643646 ) ;
644647 }
645648 CurieError :: InvalidIRI ( iri) => {
646- self . processor_graph . borrow_mut ( ) . emit (
647- PGType :: UnresolvedCurie ,
649+ self . processor_graph . borrow_mut ( ) . emit_message (
650+ MessageType :: UnresolvedCurie ,
648651 & format ! (
649652 "Invalid CURIE: {value} (expanded to invalid IRI value <{iri}>)" ,
650653 ) ,
651654 ) ;
652655 }
653656 CurieError :: ExpansionError ( ExpansionError :: Invalid ) => {
654- self . processor_graph . borrow_mut ( ) . emit (
655- PGType :: UnresolvedCurie ,
657+ self . processor_graph . borrow_mut ( ) . emit_message (
658+ MessageType :: UnresolvedCurie ,
656659 & format ! ( "Invalid CURIE: {value} (no such prefix defined)" ) ,
657660 ) ;
658661 }
@@ -709,8 +712,8 @@ impl<'e, 'rp, 'p: 'rp, H: HostLanguage> Resolver<'e, 'rp, 'p, H> {
709712 }
710713
711714 fn report_invalid_iri ( & self , iri_err : IriParseError , value : & str ) {
712- self . processor_graph . borrow_mut ( ) . emit (
713- PGType :: Warning ,
715+ self . processor_graph . borrow_mut ( ) . emit_message (
716+ MessageType :: Warning ,
714717 & format ! ( "Invalid IRI: <{}> ({})" , value, iri_err) ,
715718 ) ;
716719 }
@@ -1482,7 +1485,6 @@ struct RDFaProcessor<'o, 'p> {
14821485}
14831486
14841487struct OutputGraph < ' o > ( & ' o mut oxrdf:: Graph ) ;
1485- struct ProcessorGraph < ' p > ( & ' p mut oxrdf:: Graph ) ;
14861488
14871489impl < ' o > OutputGraph < ' o > {
14881490 fn emit ( & mut self , tr : TripleRef ) {
@@ -1491,51 +1493,6 @@ impl<'o> OutputGraph<'o> {
14911493 }
14921494}
14931495
1494- impl < ' p > ProcessorGraph < ' p > {
1495- fn emit ( & mut self , pg_type : PGType , msg : & str ) {
1496- let warning_subj: oxrdf:: NamedOrBlankNode = oxrdf:: BlankNode :: default ( ) . into ( ) ;
1497- let pg_type: oxrdf:: NamedNodeRef = pg_type. into ( ) ;
1498- // new bnode is-a PGClass
1499- let node = TripleRef :: new ( & warning_subj, oxrdf:: vocab:: rdf:: TYPE , pg_type) ;
1500- // add description
1501- let desc = TripleRef :: new (
1502- & warning_subj,
1503- vocabs:: dc:: DESCRIPTION ,
1504- oxrdf:: LiteralRef :: new_simple_literal ( msg) ,
1505- ) ;
1506- trace ! ( triple = %node, "emitting processor triple (type)" ) ;
1507- self . 0 . insert ( node) ;
1508- trace ! ( triple = %desc, "emitting processor triple (description)" ) ;
1509- self . 0 . insert ( desc) ;
1510- }
1511- }
1512-
1513- enum PGType {
1514- // Bases
1515- Error ,
1516- Warning ,
1517- // Derived
1518- DocumentError ,
1519- VocabReferenceError ,
1520- UnresolvedCurie ,
1521- UnresolvedTerm ,
1522- PrefixRedefinition ,
1523- }
1524-
1525- impl From < PGType > for oxrdf:: NamedNodeRef < ' static > {
1526- fn from ( val : PGType ) -> Self {
1527- match val {
1528- PGType :: Error => vocabs:: rdfa:: ERROR ,
1529- PGType :: Warning => vocabs:: rdfa:: WARNING ,
1530- PGType :: DocumentError => vocabs:: rdfa:: DOCUMENT_ERROR ,
1531- PGType :: VocabReferenceError => vocabs:: rdfa:: VOCAB_REFERENCE_ERROR ,
1532- PGType :: UnresolvedCurie => vocabs:: rdfa:: UNRESOLVED_CURIE ,
1533- PGType :: UnresolvedTerm => vocabs:: rdfa:: UNRESOLVED_TERM ,
1534- PGType :: PrefixRedefinition => vocabs:: rdfa:: PREFIX_REDEFINITION ,
1535- }
1536- }
1537- }
1538-
15391496trait HostLanguage {
15401497 fn default_language ( ) -> Option < LanguageIdentifier > ;
15411498 fn default_vocabulary ( ) -> Option < oxrdf:: NamedNode > ;
0 commit comments