onTagResource(tag, activeTag, parentTag, rootTag) {
        const tagExpanded = RdfXmlParser.expandPrefixedTerm(tag.name, activeTag.ns, this);
        activeTag.childrenParseType = ParseType.PROPERTY;
        // Assume that the current node is a _typed_ node (2.13), unless we find an rdf:Description as node name
        let typedNode = true;
        if (tagExpanded.uri === RdfXmlParser.RDF) {
            // Check forbidden property element names
            if (!rootTag && RdfXmlParser.FORBIDDEN_NODE_ELEMENTS.indexOf(tagExpanded.local) >= 0) {
                throw this.newParseError(`Illegal node element name: ${tagExpanded.local}`);
            }
            switch (tagExpanded.local) {
                case 'RDF':
                    // Tags under <rdf:RDF> must always be resources
                    activeTag.childrenParseType = ParseType.RESOURCE;
                case 'Description':
                    typedNode = false;
            }
        }
        const predicates = [];
        const objects = [];
        // Collect all attributes as triples
        // Assign subject value only after all attributes have been processed, because baseIRI may change the final val
        let activeSubjectValue = null;
        let claimSubjectNodeId = false;
        let subjectValueBlank = false;
        let explicitType = null;
        for (const attributeKey in tag.attributes) {
            const attributeValue = tag.attributes[attributeKey];
            const attributeKeyExpanded = RdfXmlParser.expandPrefixedTerm(attributeKey, activeTag.ns, this);
            if (parentTag && attributeKeyExpanded.uri === RdfXmlParser.RDF) {
                switch (attributeKeyExpanded.local) {
                    case 'about':
                        if (activeSubjectValue) {
                            throw this.newParseError(`Only one of rdf:about, rdf:nodeID and rdf:ID can be present, \
while ${attributeValue} and ${activeSubjectValue} where found.`);
                        }
                        activeSubjectValue = attributeValue;
                        continue;
                    case 'ID':
                        if (activeSubjectValue) {
                            throw this.newParseError(`Only one of rdf:about, rdf:nodeID and rdf:ID can be present, \
while ${attributeValue} and ${activeSubjectValue} where found.`);
                        }
                        this.validateNcname(attributeValue);
                        activeSubjectValue = '#' + attributeValue;
                        claimSubjectNodeId = true;
                        continue;
                    case 'nodeID':
                        if (activeSubjectValue) {
                            throw this.newParseError(`Only one of rdf:about, rdf:nodeID and rdf:ID can be present, \
while ${attributeValue} and ${activeSubjectValue} where found.`);
                        }
                        this.validateNcname(attributeValue);
                        activeSubjectValue = attributeValue;
                        subjectValueBlank = true;
                        continue;
                    case 'bagID':
                        throw this.newParseError(`rdf:bagID is not supported.`);
                    case 'type':
                        // Emit the rdf:type later as named node instead of the default literal
                        explicitType = attributeValue;
                        continue;
                    case 'aboutEach':
                        throw this.newParseError(`rdf:aboutEach is not supported.`);
                    case 'aboutEachPrefix':
                        throw this.newParseError(`rdf:aboutEachPrefix is not supported.`);
                    case 'li':
                        throw this.newParseError(`rdf:li on node elements are not supported.`);
                }
            }
            else if (attributeKeyExpanded.uri === RdfXmlParser.XML) {
                if (attributeKeyExpanded.local === 'lang') {
                    activeTag.language = attributeValue === '' ? null : attributeValue.toLowerCase();
                    continue;
                }
                else if (attributeKeyExpanded.local === 'base') {
                    // SAX Parser does not expand xml:base, based on DOCTYPE, so we have to do it manually
                    activeTag.baseIRI = relative_to_absolute_iri_1.resolve(attributeValue, activeTag.baseIRI);
                    continue;
                }
            }
            // Interpret attributes at this point as properties on this node,
            // but we ignore attributes that have no prefix or known expanded URI
            if (attributeKeyExpanded.prefix !== 'xml' && attributeKeyExpanded.uri) {
                predicates.push(this.uriToNamedNode(attributeKeyExpanded.uri + attributeKeyExpanded.local));
                objects.push(attributeValue);
            }
        }
        // Create the subject value _after_ all attributes have been processed
        if (activeSubjectValue !== null) {
            activeTag.subject = subjectValueBlank
                ? this.dataFactory.blankNode(activeSubjectValue) : this.valueToUri(activeSubjectValue, activeTag);
            if (claimSubjectNodeId) {
                this.claimNodeId(activeTag.subject);
            }
        }
        // Force the creation of a subject if it doesn't exist yet
        if (!activeTag.subject) {
            activeTag.subject = this.dataFactory.blankNode();
        }
        // Emit the type if we're at a typed node
        if (typedNode) {
            const type = this.uriToNamedNode(tagExpanded.uri + tagExpanded.local);
            this.emitTriple(activeTag.subject, this.dataFactory.namedNode(RdfXmlParser.RDF + 'type'), type, parentTag ? parentTag.reifiedStatementId : null);
        }
        if (parentTag) {
            // If the parent tag defined a predicate, add the current tag as property value
            if (parentTag.predicate) {
                if (parentTag.childrenCollectionSubject) {
                    // RDF:List-based properties
                    const linkTerm = this.dataFactory.blankNode();
                    // Emit <x> <p> <current-chain> OR <previous-chain> <rdf:rest> <current-chain>
                    this.emitTriple(parentTag.childrenCollectionSubject, parentTag.childrenCollectionPredicate, linkTerm, parentTag.reifiedStatementId);
                    // Emit <current-chain> <rdf:first> value
                    this.emitTriple(linkTerm, this.dataFactory.namedNode(RdfXmlParser.RDF + 'first'), activeTag.subject, activeTag.reifiedStatementId);
                    // Store <current-chain> in the parent node
                    parentTag.childrenCollectionSubject = linkTerm;
                    parentTag.childrenCollectionPredicate = this.dataFactory.namedNode(RdfXmlParser.RDF + 'rest');
                }
                else { // !parentTag.predicateEmitted
                    // Set-based properties
                    this.emitTriple(parentTag.subject, parentTag.predicate, activeTag.subject, parentTag.reifiedStatementId);
                    // Emit pending properties on the parent tag that had no defined subject yet.
                    for (let i = 0; i < parentTag.predicateSubPredicates.length; i++) {
                        this.emitTriple(activeTag.subject, parentTag.predicateSubPredicates[i], parentTag.predicateSubObjects[i], null);
                    }
                    // Cleanup so we don't emit them again when the parent tag is closed
                    parentTag.predicateSubPredicates = [];
                    parentTag.predicateSubObjects = [];
                    parentTag.predicateEmitted = true;
                }
            }
            // Emit all collected triples
            for (let i = 0; i < predicates.length; i++) {
                const object = this.dataFactory.literal(objects[i], activeTag.datatype || activeTag.language);
                this.emitTriple(activeTag.subject, predicates[i], object, parentTag.reifiedStatementId);
            }
            // Emit the rdf:type as named node instead of literal
            if (explicitType) {
                this.emitTriple(activeTag.subject, this.dataFactory.namedNode(RdfXmlParser.RDF + 'type'), this.uriToNamedNode(explicitType), null);
            }
        }
    }
/**
     * Handle the given node element in resource-mode.
     * @param {QualifiedTag} tag A SAX tag.
     * @param {IActiveTag} activeTag The currently active tag.
     * @param {IActiveTag} parentTag The parent tag or null.
     * @param {boolean} rootTag If we are currently processing the root tag.
     */
Handle the given node element in resource-mode.
@param {QualifiedTag} tag A SAX tag.
@param {IActiveTag} activeTag The currently active tag.
@param {IActiveTag} parentTag The parent tag or null.
@param {boolean} rootTag If we are currently processing the root tag.
Handle the given node element in resource - mode . @param { QualifiedTag } tag A SAX tag . @param { IActiveTag } activeTag The currently active tag . @param { IActiveTag } parentTag The parent tag or null . @param { boolean } rootTag If we are currently processing the root tag .
onTagResource(tag, activeTag, parentTag, rootTag) {
        const tagExpanded = RdfXmlParser.expandPrefixedTerm(tag.name, activeTag.ns, this);
        activeTag.childrenParseType = ParseType.PROPERTY;
        let typedNode = true;
        if (tagExpanded.uri === RdfXmlParser.RDF) {
            if (!rootTag && RdfXmlParser.FORBIDDEN_NODE_ELEMENTS.indexOf(tagExpanded.local) >= 0) {
                throw this.newParseError(`Illegal node element name: ${tagExpanded.local}`);
            }
            switch (tagExpanded.local) {
                case 'RDF':
                    activeTag.childrenParseType = ParseType.RESOURCE;
                case 'Description':
                    typedNode = false;
            }
        }
        const predicates = [];
        const objects = [];
        let activeSubjectValue = null;
        let claimSubjectNodeId = false;
        let subjectValueBlank = false;
        let explicitType = null;
        for (const attributeKey in tag.attributes) {
            const attributeValue = tag.attributes[attributeKey];
            const attributeKeyExpanded = RdfXmlParser.expandPrefixedTerm(attributeKey, activeTag.ns, this);
            if (parentTag && attributeKeyExpanded.uri === RdfXmlParser.RDF) {
                switch (attributeKeyExpanded.local) {
                    case 'about':
                        if (activeSubjectValue) {
                            throw this.newParseError(`Only one of rdf:about, rdf:nodeID and rdf:ID can be present, \
while ${attributeValue} and ${activeSubjectValue} where found.`);
                        }
                        activeSubjectValue = attributeValue;
                        continue;
                    case 'ID':
                        if (activeSubjectValue) {
                            throw this.newParseError(`Only one of rdf:about, rdf:nodeID and rdf:ID can be present, \
while ${attributeValue} and ${activeSubjectValue} where found.`);
                        }
                        this.validateNcname(attributeValue);
                        activeSubjectValue = '#' + attributeValue;
                        claimSubjectNodeId = true;
                        continue;
                    case 'nodeID':
                        if (activeSubjectValue) {
                            throw this.newParseError(`Only one of rdf:about, rdf:nodeID and rdf:ID can be present, \
while ${attributeValue} and ${activeSubjectValue} where found.`);
                        }
                        this.validateNcname(attributeValue);
                        activeSubjectValue = attributeValue;
                        subjectValueBlank = true;
                        continue;
                    case 'bagID':
                        throw this.newParseError(`rdf:bagID is not supported.`);
                    case 'type':
                        explicitType = attributeValue;
                        continue;
                    case 'aboutEach':
                        throw this.newParseError(`rdf:aboutEach is not supported.`);
                    case 'aboutEachPrefix':
                        throw this.newParseError(`rdf:aboutEachPrefix is not supported.`);
                    case 'li':
                        throw this.newParseError(`rdf:li on node elements are not supported.`);
                }
            }
            else if (attributeKeyExpanded.uri === RdfXmlParser.XML) {
                if (attributeKeyExpanded.local === 'lang') {
                    activeTag.language = attributeValue === '' ? null : attributeValue.toLowerCase();
                    continue;
                }
                else if (attributeKeyExpanded.local === 'base') {
                    activeTag.baseIRI = relative_to_absolute_iri_1.resolve(attributeValue, activeTag.baseIRI);
                    continue;
                }
            }
            if (attributeKeyExpanded.prefix !== 'xml' && attributeKeyExpanded.uri) {
                predicates.push(this.uriToNamedNode(attributeKeyExpanded.uri + attributeKeyExpanded.local));
                objects.push(attributeValue);
            }
        }
        if (activeSubjectValue !== null) {
            activeTag.subject = subjectValueBlank
                ? this.dataFactory.blankNode(activeSubjectValue) : this.valueToUri(activeSubjectValue, activeTag);
            if (claimSubjectNodeId) {
                this.claimNodeId(activeTag.subject);
            }
        }
        if (!activeTag.subject) {
            activeTag.subject = this.dataFactory.blankNode();
        }
        if (typedNode) {
            const type = this.uriToNamedNode(tagExpanded.uri + tagExpanded.local);
            this.emitTriple(activeTag.subject, this.dataFactory.namedNode(RdfXmlParser.RDF + 'type'), type, parentTag ? parentTag.reifiedStatementId : null);
        }
        if (parentTag) {
            if (parentTag.predicate) {
                if (parentTag.childrenCollectionSubject) {
                    const linkTerm = this.dataFactory.blankNode();
                    this.emitTriple(parentTag.childrenCollectionSubject, parentTag.childrenCollectionPredicate, linkTerm, parentTag.reifiedStatementId);
                    this.emitTriple(linkTerm, this.dataFactory.namedNode(RdfXmlParser.RDF + 'first'), activeTag.subject, activeTag.reifiedStatementId);
                    parentTag.childrenCollectionSubject = linkTerm;
                    parentTag.childrenCollectionPredicate = this.dataFactory.namedNode(RdfXmlParser.RDF + 'rest');
                }
                else { 
                    this.emitTriple(parentTag.subject, parentTag.predicate, activeTag.subject, parentTag.reifiedStatementId);
                    for (let i = 0; i < parentTag.predicateSubPredicates.length; i++) {
                        this.emitTriple(activeTag.subject, parentTag.predicateSubPredicates[i], parentTag.predicateSubObjects[i], null);
                    }
                    parentTag.predicateSubPredicates = [];
                    parentTag.predicateSubObjects = [];
                    parentTag.predicateEmitted = true;
                }
            }
            for (let i = 0; i < predicates.length; i++) {
                const object = this.dataFactory.literal(objects[i], activeTag.datatype || activeTag.language);
                this.emitTriple(activeTag.subject, predicates[i], object, parentTag.reifiedStatementId);
            }
            if (explicitType) {
                this.emitTriple(activeTag.subject, this.dataFactory.namedNode(RdfXmlParser.RDF + 'type'), this.uriToNamedNode(explicitType), null);
            }
        }
    }
onTagResource ( tag , activeTag , parentTag , rootTag ) { const tagExpanded = RdfXmlParser . expandPrefixedTerm ( tag . name , activeTag . ns , this ) ; activeTag . childrenParseType = ParseType . PROPERTY ; let typedNode = true ; if ( tagExpanded . uri === RdfXmlParser . RDF ) { if ( ! rootTag && RdfXmlParser . FORBIDDEN_NODE_ELEMENTS . indexOf ( tagExpanded . local ) >= 0 ) { throw this . newParseError ( ` ${ tagExpanded . local } ` ) ; } switch ( tagExpanded . local ) { case 'RDF' : activeTag . childrenParseType = ParseType . RESOURCE ; case 'Description' : typedNode = false ; } } const predicates = [ ] ; const objects = [ ] ; let activeSubjectValue = null ; let claimSubjectNodeId = false ; let subjectValueBlank = false ; let explicitType = null ; for ( const attributeKey in tag . attributes ) { const attributeValue = tag . attributes [ attributeKey ] ; const attributeKeyExpanded = RdfXmlParser . expandPrefixedTerm ( attributeKey , activeTag . ns , this ) ; if ( parentTag && attributeKeyExpanded . uri === RdfXmlParser . RDF ) { switch ( attributeKeyExpanded . local ) { case 'about' : if ( activeSubjectValue ) { throw this . newParseError ( ` \
 ${ attributeValue } ${ activeSubjectValue } ` ) ; } activeSubjectValue = attributeValue ; continue ; case 'ID' : if ( activeSubjectValue ) { throw this . newParseError ( ` \
 ${ attributeValue } ${ activeSubjectValue } ` ) ; } this . validateNcname ( attributeValue ) ; activeSubjectValue = '#' + attributeValue ; claimSubjectNodeId = true ; continue ; case 'nodeID' : if ( activeSubjectValue ) { throw this . newParseError ( ` \
 ${ attributeValue } ${ activeSubjectValue } ` ) ; } this . validateNcname ( attributeValue ) ; activeSubjectValue = attributeValue ; subjectValueBlank = true ; continue ; case 'bagID' : throw this . newParseError ( ` ` ) ; case 'type' : explicitType = attributeValue ; continue ; case 'aboutEach' : throw this . newParseError ( ` ` ) ; case 'aboutEachPrefix' : throw this . newParseError ( ` ` ) ; case 'li' : throw this . newParseError ( ` ` ) ; } } else if ( attributeKeyExpanded . uri === RdfXmlParser . XML ) { if ( attributeKeyExpanded . local === 'lang' ) { activeTag . language = attributeValue === '' ? null : attributeValue . toLowerCase ( ) ; continue ; } else if ( attributeKeyExpanded . local === 'base' ) { activeTag . baseIRI = relative_to_absolute_iri_1 . resolve ( attributeValue , activeTag . baseIRI ) ; continue ; } } if ( attributeKeyExpanded . prefix !== 'xml' && attributeKeyExpanded . uri ) { predicates . push ( this . uriToNamedNode ( attributeKeyExpanded . uri + attributeKeyExpanded . local ) ) ; objects . push ( attributeValue ) ; } } if ( activeSubjectValue !== null ) { activeTag . subject = subjectValueBlank ? this . dataFactory . blankNode ( activeSubjectValue ) : this . valueToUri ( activeSubjectValue , activeTag ) ; if ( claimSubjectNodeId ) { this . claimNodeId ( activeTag . subject ) ; } } if ( ! activeTag . subject ) { activeTag . subject = this . dataFactory . blankNode ( ) ; } if ( typedNode ) { const type = this . uriToNamedNode ( tagExpanded . uri + tagExpanded . local ) ; this . emitTriple ( activeTag . subject , this . dataFactory . namedNode ( RdfXmlParser . RDF + 'type' ) , type , parentTag ? parentTag . reifiedStatementId : null ) ; } if ( parentTag ) { if ( parentTag . predicate ) { if ( parentTag . childrenCollectionSubject ) { const linkTerm = this . dataFactory . blankNode ( ) ; this . emitTriple ( parentTag . childrenCollectionSubject , parentTag . childrenCollectionPredicate , linkTerm , parentTag . reifiedStatementId ) ; this . emitTriple ( linkTerm , this . dataFactory . namedNode ( RdfXmlParser . RDF + 'first' ) , activeTag . subject , activeTag . reifiedStatementId ) ; parentTag . childrenCollectionSubject = linkTerm ; parentTag . childrenCollectionPredicate = this . dataFactory . namedNode ( RdfXmlParser . RDF + 'rest' ) ; } else { this . emitTriple ( parentTag . subject , parentTag . predicate , activeTag . subject , parentTag . reifiedStatementId ) ; for ( let i = 0 ; i < parentTag . predicateSubPredicates . length ; i ++ ) { this . emitTriple ( activeTag . subject , parentTag . predicateSubPredicates [ i ] , parentTag . predicateSubObjects [ i ] , null ) ; } parentTag . predicateSubPredicates = [ ] ; parentTag . predicateSubObjects = [ ] ; parentTag . predicateEmitted = true ; } } for ( let i = 0 ; i < predicates . length ; i ++ ) { const object = this . dataFactory . literal ( objects [ i ] , activeTag . datatype || activeTag . language ) ; this . emitTriple ( activeTag . subject , predicates [ i ] , object , parentTag . reifiedStatementId ) ; } if ( explicitType ) { this . emitTriple ( activeTag . subject , this . dataFactory . namedNode ( RdfXmlParser . RDF + 'type' ) , this . uriToNamedNode ( explicitType ) , null ) ; } } }
Handle the given node element in resource-mode.
Handle the given node element in resource - mode .
// Assume that the current node is a _typed_ node (2.13), unless we find an rdf:Description as node name // Check forbidden property element names // Tags under <rdf:RDF> must always be resources // Collect all attributes as triples // Assign subject value only after all attributes have been processed, because baseIRI may change the final val // Emit the rdf:type later as named node instead of the default literal // SAX Parser does not expand xml:base, based on DOCTYPE, so we have to do it manually // Interpret attributes at this point as properties on this node, // but we ignore attributes that have no prefix or known expanded URI // Create the subject value _after_ all attributes have been processed // Force the creation of a subject if it doesn't exist yet // Emit the type if we're at a typed node // If the parent tag defined a predicate, add the current tag as property value // RDF:List-based properties // Emit <x> <p> <current-chain> OR <previous-chain> <rdf:rest> <current-chain> // Emit <current-chain> <rdf:first> value // Store <current-chain> in the parent node // !parentTag.predicateEmitted // Set-based properties // Emit pending properties on the parent tag that had no defined subject yet. // Cleanup so we don't emit them again when the parent tag is closed // Emit all collected triples // Emit the rdf:type as named node instead of literal