Processing an xml catalog in xslt

Subject: Processing an xml catalog in xslt
From: Nicolas Mailhot <Nicolas.Mailhot@xxxxxxxxxxx>
Date: Tue, 29 Jun 2004 14:04:09 +0200
Hi all,

I currently need to feed an xml catalog to a java process that is too
dumb to process it. So I was thinking of extracting the values I need
into a stupid property file using an xsl.

The problem is, I've never processed a file with such a complex
namespace as this xml catalog, and I'm failing miserably. The catalog
file looks like this :

<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog
V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd";>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
  <public publicId="ISO 8879:1986//ENTITIES Publishing//EN" uri="xml-
dtd-4.2-1.0-24/ent/iso-pub.ent"/>

[...]

<rewriteURI uriStartString="http://www.oasis-open.org/docbook/xml/4.2";
rewritePrefix="xml-dtd-4.2-1.0-24"/>
</catalog>

All I need basically right now is the value of rewritePrefix for this
last entry. The best solution I've found now is

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
  <xsl:output method="text" indent="yes" encoding="UTF-8"/>
  <xsl:strip-space elements="*"/>
 
  <xsl:template match="*
[@uriStartString='http://www.oasis-open.org/docbook/xml/4.2'][1]">
<xsl:value-of select="concat('docbook.dtd.subroot=',@rewritePrefix)"/>
  </xsl:template>
 
</xsl:stylesheet>

But I don't like much to use a * to match rewriteURI. However so far I
didn't manage to replace it with something that still works. Anyone got
a better solution ?

Regards,

-- 
Nicolas Mailhot


Current Thread