xsl-list
[Top] [All Lists]

RE: namespace-alias problem

2005-01-23 09:37:11
xsl:namespace-alias applies only to literal result elements. So if you write

  <x:template...>

the namespace will be changed, but if you write 

  <xsl:element name="x:template"

then it won't.

So you should either change

  <xsl:element name="x:template">

to

  <xsl:element name="xsl:template">

or you should change

<xsl:element name="x:template">
  <xsl:attribute name="match">
    <xsl:value-of select="person"/>
  </xsl:attribute>
  
  <BODY>
    This is the body text
  <x:apply-templates>
    <x:with-param name="path" select="person"/>
  </x:apply-templates>
  </BODY>
 
</xsl:element>

to

<x:template match="{person}">  
  <BODY>
    This is the body text
  <x:apply-templates>
    <x:with-param name="path" select="person"/>
  </x:apply-templates>
  </BODY> 
</x:template>

Michael Kay
http://www.saxonica.com/

 

-----Original Message-----
From: Touchtel [mailto:omprakashv(_at_)touchtelindia(_dot_)net] 
Sent: 23 January 2005 05:15
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] namespace-alias problem

Hi,
    Iam using a stylesheet to generate another stylesheet and 
having some
problems like the processor not recognising the aliased 
namespace (x:) the
2nd time around. The following are my xml and  and input and output
stylesheet snippets. The snippets are quite large but I am 
not sure how to
make these smaller than this.

Regards,
Omprakash.V


      school.xml

      <?xml version="1.0" encoding="UTF-8"?>

      <school version="1.0">
        <student name="person"/>
        <student name="name" type="ps:data"/>
      </school>


      student.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:x
="http://www.w3.org/1999/XSL/TransformAlias"; 
exclude-result-prefixes="x"
version="1.0">

<xsl:namespace-alias stylesheet-prefix="x" result-prefix="xsl"/>

<xsl:output method="xml" indent="yes" encoding="iso-8859-1"/>

<xsl:template match="school">
    <x:stylesheet version="1.0" xmlns:xsl
="http://www.w3.org/1999/XSL/Transform";>
<x:strip-space elements="*"/>

<xsl:element name="x:template">
<xsl:attribute name="match">
<xsl:value-of select="person"/>
</xsl:attribute>

<BODY>
    This is the body text
<x:apply-templates>
 <x:with-param name="path" select="person"/>
</x:apply-templates>
  </BODY>

</xsl:element>

<xsl:apply-templates />

</x:stylesheet>

</xsl:template>

<xsl:template match="student">

<xsl:if test="not(@name='person')">

<xsl:element name="x:template">
<xsl:attribute name="match">
<xsl:value-of select="@name" />
</xsl:attribute>

<a href="#">This is a student <x:value-of select="@name"/></a>
</xsl:element>

</xsl:if>

</xsl:template>

</xsl:stylesheet>












And the resulting stylesheet is

<?xml version="1.0" encoding="iso-8859-1"?>
<x:stylesheet xmlns:x="http://www.w3.org/1999/XSL/Transform"; 
version="1.0">
<x:strip-space elements="*"/>
<x:template 
xmlns:x="http://www.w3.org/1999/XSL/TransformAlias"; match="">
<BODY>
    This is the body text
<x:apply-templates>
<x:with-param name="" select=""/>
</x:apply-templates>
</BODY>
</x:template>


     <x:template xmlns:x="http://www.w3.org/1999/XSL/TransformAlias";
match="name">

<a href="#">This is a student <x:value-of
xmlns:x="http://www.w3.org/1999/XSL/Transform"; select="@name"/>
</a>
</x:template>
  </x:stylesheet>













--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>