[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Why do the namespace appears in transformation ?

Subject: Re: Why do the namespace appears in transformation ?
From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx>
Date: Fri, 20 Aug 2010 10:15:50 +0200
Re:  Why do the namespace appears in transformation ?
Fabien,

your output is non-XML since it does not contain a single root element.

Just adding "<result>" before "<xsl:for-each-group>" and "</result>"
after "</xsl:for-each-group>" gives below output.
The "xsl" namespace prefix needs to be defined somewhere if you use it.

Is this what you want?

$ saxon xfrom2.xsl data.xml | tidy -q -xml
<?xml version="1.0" encoding="utf-8"?>
<result xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()[(MTF_NUMERO_TABLEAU = '2')]" />
2,
<xsl:template match="node()[(MTF_NUMERO_TABLEAU = '3')]" />
3,</result>

$


Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Developer, XML Compiler, L3
WebSphere DataPower SOA Appliances
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294



From:       "Fabien Tillier" <f.tillier@xxxxxxxx>
To:         <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Date:       08/20/2010 08:52 AM
Subject:     Why do the namespace appears in transformation ?



Hi List.
I am trying to generate an XSL template from an XML file that describes
some filters.
So, basically, I get
<Results>
   <Row>
      <MTF_NUMERO_TABLEAU>2</MTF_NUMERO_TABLEAU>
      <TA_TITRE_A>Titre 1</TA_TITRE_A>
   </Row>
   <Row>
      <MTF_NUMERO_TABLEAU>3</MTF_NUMERO_TABLEAU>
      <TA_TITRE_A>Titre 2</TA_TITRE_A>
   </Row>
 </Results>

I am parsing it with (not finished, of course)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xsl"
 xmlns:xso="dummy"
  >
 <xsl:output method = "xml" encoding="UTF-8"/>
 <!--  When transforming, all xso namespace elements will become xsl -->
 <xsl:namespace-alias stylesheet-prefix="xso" result-prefix="xsl"/>
 <xsl:template match="/Results">
             <xsl:for-each-group select="Row"
group-by="MTF_NUMERO_TABLEAU">
                         <xsl:variable name="numtableau">
                                     <xsl:value-of
select="current-grouping-key()"/>
                         </xsl:variable>
                         <xso:template match="node()[(MTF_NUMERO_TABLEAU =
'{$numtableau}')]">
                                     <!--Do something-->
                         </xso:template>
                         <xsl:value-of select="current-grouping-key()"/>,

             </xsl:for-each-group>
 </xsl:template>
 <xsl:template match="Row">

 </xsl:template>
</xsl:stylesheet>



The output (with Kernow) is

<?xml version="1.0" encoding="UTF-8"?>
<xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
match="node()[(MTF_NUMERO_TABLEAU = '2')]"/>2,
<xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
match="node()[(MTF_NUMERO_TABLEAU = '3')]"/>3

Which is almost what I want....
But, how can I get rid of the xmlns declaration in each <xsl:template
section ?
(So that to get
<?xml version="1.0" encoding="UTF-8"?>
<xsl:template match="node()[(MTF_NUMERO_TABLEAU = '2')]"/>2,

<xsl:template match="node()[(MTF_NUMERO_TABLEAU = '3')]"/>3
)

Thanks in advance
Regards,
Fabien

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.