views:

21

answers:

0

I have a file that contains a default namespace declaration, first few lines of one such here:

<?xml version="1.0" encoding="UTF-8"?>
<dodavka xmlns="urn:CZ-RVV-IS-VaV-XML-NS:data-1.2.2" xmlns:v="urn:xmlns:mathan.vklap.annotations-1.0" v:faze="finalni" struktura="RIV09A">
  <zahlavi v:posledni-zmena="06.09.2009 21:28 +0200 1.4.46">
    <rozsah>
      <informacni-oblast>RIV</informacni-oblast>
      <obdobi-sberu>2009</obdobi-sberu>
        ...

I need to extract this and use it to modify an existing transform before I run it. Evan Lenz kindly furnished me with a transform that does that, given a parameter. I'm now trying to extract it directly from the XML file that contains this declaration, using the document() function, but not getting anything out. The transform (at the end of this post) runs and produces a modified copy of the original transform, but the contents of the default namespace declaration are empty:

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:v="urn:xmlns:mathan.vklap.annotations-1.0" version="2.0" xpath-default-namespace="">

How do I access this attribute? Do I need to declare that default namespace before I can get anything out of the file? If so, that makes the whole thing impossible, since it's exactly that namespace ID that I don't know and need to get. Do I have some stupid mistake in my XSL? I've tried all sorts of variations and either get an empty attribute or the transform doesn't run at all.

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;

  <!-- Pass in the new namespace URI as a stylesheet parameter -->
  <!-- By default, copy everything as is -->
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

  <!-- But update the value of @xpath-default-namespace -->
  <xsl:template match="@xpath-default-namespace">
    <xsl:attribute name="{name()}" namespace="{namespace-uri()}">
      <xsl:value-of select="document('C:\Documents and Settings\nm\Plocha\Souckova\Priklady\RIV09-MK0-00023272_def,01.vav')/dodavka@xmlns"/>
    </xsl:attribute>
  </xsl:template>

</xsl:stylesheet>