Re: Problems getting start_prefix_mapping to fire
Michael Ludwig <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <20100331233219.GB3832@wladimir> |
Kjetil Kjernsmo schrieb am 31.03.2010 um 23:59:31 (+0200):
> I need to remove some namespace prefix mappings from my result
> document. Now, the problem is that these prefixes occur in attribute
> values, this is actually RDFa.
> As you can see, it needs to retain e.g. the dbp:-prefix but drop the
> sub:- prefix, both of which only occur in attribute values.
I wouldn't use SAX, which is low-level and tedious. I'd use XSLT, which
is a high-level tool, that lets the processor do the work, not the
human.
You could tackle this as a variation on the identity template patter.
Replace the document element that defines all the namespaces which one
of your liking that only has the namespaces you want.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/*">
<!-- add all the namespace declarations you want here -->
<html xmlns="http://www.w3.org/1999/xhtml">
<xsl:apply-templates select="@*|node()"/>
</html>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Then, use a processor to do the transformation:
xsltproc identity.xsl dbpedia-mustang-range.input.xhtml
--
Michael Ludwig
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs