Re: [xslt] Problem with creating namespace in the stylesheet



Petr Novak wrote:

That is problem, because I don't know this namespace - it is parsed from the
processing XML document. Exactly the situation is:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xmlns:xslo="http://www.w3.org/1999/XSL/TransformAlias";
 xmlns:schema="http://relaxng.org/ns/structure/1.0";>

<xsl:import href="relaxng-core.xsl"/>
<xsl:output method="xml" encoding="iso-8859-1" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:namespace-alias stylesheet-prefix="xslo" result-prefix="xsl"/>

<xsl:template match="/">
	<!-- Now I take the namespace -->
	<xsl:variable name="netopeerns" value="schema:grammar/@ns"/>

	<!-- Now I create the <xslo:stylesheet> element -->
	<xsl:element name="xslo:element">
		<!-- Now it is created the <xslo:stylesheet> element. I need to add the namespace to it with "netopeer" prefix and the same value as the value of the $netopeerns is -->
		<!-- e.g., if the value of the $netopeer variable is "http://www.liberouter.org";, I need to obtain output as a: <xslo:stylesheet xmlns:netopeer="http://www.liberouter.org"/> -->

<!-- Processing the rest of the document... -->

I still don't see your problem. You can generate your elements using:

<xsl:element name="myElementInNetoPeerNS" namespace="{$netopeerns}">
  ...
</xsl:element>

Namespace declaration will be added automatically in this case. Does it solve your problem?

				Jirka

--
------------------------------------------------------------------
  Jirka Kosek     e-mail: jirka kosek cz     http://www.kosek.cz
------------------------------------------------------------------
  Profesionální školení a poradenství v oblasti technologií XML.
     Podívejte se na náš nově spuštěný web http://DocBook.cz
------------------------------------------------------------------

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]