xpath-default-namespace="urn:CZ-RVV-IS-VaV-XML-NS:data-1.2.2"
The problem is that this value changes from time to time, and my transform
suddenly stops working, until I look at an example from the new file,
extract this namespace ID and put it in the transform, whereby the transform
stops working for old files. Is there a way to pass this as a parameter? I
have tried the parameter syntaxes that I looked up in various tutorials, but
none have worked for this particular use.
Pete
--
This e-mail address is fake, to keep spammers and their address harvesters
out of my hair. If you want to get in touch personally, I am 'pdanes' and I
use yahoo mail. But please use the newsgroup when possible, so that all may
benefit from the exchange of ideas.
But a two-pass solution seems a popular way to deal with similar issues -
making a transform to re-configure the original transform, then executing
the changed transform. Since the XSL transform is XML, theoretically easily
changed with XSL, this might be the way to go. I need to get this first line
in the source document:
<dodavka xmlns="urn:CZ-RVV-IS-VaV-XML-NS:data-1.2.1"
xmlns:v="urn:xmlns:mathan.vklap.annotations-1.0" v:faze="finalni"
struktura="RIV08A">
and extract the default namespace declaration,
[xmlns="urn:CZ-RVV-IS-VaV-XML-NS:data-1.2.1"] part, get its value and insert
it as an xpath-default-namespace attribute into the first line of the
original transform:
<xsl:transform version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:v="urn:xmlns:mathan.vklap.annotations-1.0"
xpath-default-namespace="urn:CZ-RVV-IS-VaV-XML-NS:data-1.2.2"
>
This, in fact, is exactly a case where I need such a change. The source XML
namespace ends in 1.2.1 but the transform has namespace ...1.2.2, which
makes the whole transform do nothing, since it's looking at the wrong
namespace.
Is this a viable path, or will I run into the same namespace problems? I'm
trying it now, but no results yet. I'm using Saxon, but not getting anything
at all - no error messages and no output. Here's the XSL as I have it now:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:templates match="dodavka">
<xsl:value-of select="@xmlns">
</xsl:template>
</xsl:transform>
Pete
"Petr Danes" <skrusp...@no.spam> p锟絜 v diskusn锟絤 p锟斤拷sp锟絭ku
news:eMnz8gzd...@TK2MSFTNGP04.phx.gbl...
> <dodavka xmlns="urn:CZ-RVV-IS-VaV-XML-NS:data-1.2.1"
> xmlns:v="urn:xmlns:mathan.vklap.annotations-1.0" v:faze="finalni"
> struktura="RIV08A">
>
> and extract the default namespace declaration,
> [xmlns="urn:CZ-RVV-IS-VaV-XML-NS:data-1.2.1"] part,
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> >
> <xsl:templates match="dodavka">
> <xsl:value-of select="@xmlns">
> </xsl:template>
> </xsl:transform>
In the XSLT/XPath/XQuery data model namespace declarations are not
modelled as attributes.
If you want to find the namespace URI of the context node then simply use
namespace-uri()
or
namespace-uri(.)
--
Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/
thanks, I managed toget as far as this error message from Saxon:
Warning: on line 6 of XfXf.xsl:
The attribute axis starting at a document node will never select anything
Not sure why I was not getting anything before, probably mistyped something.
Now the new transform runs, but doesn't produce anything sensible. Here's
what I'm using:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:template match="/">
<xsl:value-of select="namespace-uri()"/>
</xsl:template>
</xsl:transform>
Tried it both with and with out the dot, same results. Output file contains
only:
<?xml version="1.0" encoding="UTF-8"?>
and nothing else.
Pete
"Martin Honnen" <maho...@yahoo.de> p�se v diskusn�m pr�spevku
news:%232B6bG1...@TK2MSFTNGP05.phx.gbl...
Pete
"Martin Honnen" <maho...@yahoo.de> p�se v diskusn�m pr�spevku
news:%232B6bG1...@TK2MSFTNGP05.phx.gbl...
> <xsl:template match="/">
> <xsl:value-of select="namespace-uri()"/>
> </xsl:template>
You need to match on an element or attribute e.g.
<xsl:template match="/*">
<xsl:value-of select="namespace-uri()"/>
</xsl:template>
or maybe
<xsl:template match="/*:dodavka">
<xsl:value-of select="namespace-uri()"/>
</xsl:template>
If you want to match on the document node then use
<xsl:template match="/">
<xsl:value-of select="namespace-uri(*)"/>
</xsl:template>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:template match="*">
<xsl:value-of select="namespace-uri()"/>
</xsl:template>
</xsl:transform>
Lots of ways to skin a cat. Now I'm working on getting it into the output.
Pete
"Martin Honnen" <maho...@yahoo.de> p�se v diskusn�m pr�spevku
news:%23jUnVg1...@TK2MSFTNGP05.phx.gbl...