Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 1st, 2010, 11:17 AM
Authorized User
 
Join Date: Oct 2010
Posts: 25
Thanks: 8
Thanked 0 Times in 0 Posts
Default namespace in output

Hello,
I have this XML code:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<doc:iso_10303_28 xmlns:exp="urn:oid:1.0.10303.28.2.1.1" xmlns:doc="urn:oid:1.0.10303.28.2.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oid:1.0.10303.28.2.1.1 ex.xsd" version="2.0">
	<exp:uos id="uos_1" description="" configuration="default" edo="">

<GE_PART210>


<document_list>
         <document  id="DOC1" >
       <id>DOC1</id>
        <revision>-</revision>
        <description>SHEET</description>
        <eco>
        	<effectivity>
        		<effdate/>
        		<changeNum/>
        	</effectivity>    	
        </eco>
        <oda>81343</oda>
        <org></org>
    </document>
    
    <document  id="DOC2">
    
      <id>DOC2 </id> 
      <revision>S9 </revision>
        <description>FASTE</description>
        <eco>
         	<effectivity>
         	 	<effdate>1995-09-15 01:00:00.0</effdate>
         	 	<changeNum>078254</changeNum>
         	 </effectivity>
         </eco>
        <oda>07482</oda>
        <org>CM</org>
    </document>
	
</document_list>
</GE_PART210>
and this xslt code
Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:exp="urn:oid:1.0.10303.28.2.1.1"
    xmlns:doc="urn:oid:1.0.10303.28.2.1.3"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                   
    exclude-result-prefixes="msxsl exp doc xsi"                
>
  
  <xsl:output method="xml" indent="yes"  omit-xml-declaration="yes"/>

    <xsl:template match="/">
            <xsl:apply-templates/>        
    </xsl:template>

  <xsl:template match="GE_PART210">
    <xsl:element name="GE_PART210">
      <xsl:text>&#xa;</xsl:text>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match="document_list">
    <xsl:element name="document-list">
      <xsl:text>&#xa;</xsl:text>
      <xsl:apply-templates />
    </xsl:element>
  </xsl:template>
  
  <xsl:template match="document">
    <xsl:element name="document">     
      <xsl:attribute name="id">
        <xsl:value-of select="@id"/>
      </xsl:attribute>
      <xsl:attribute name="revision">
        <xsl:value-of select="revision"/>
      </xsl:attribute>
      <xsl:text>&#xa;</xsl:text>      
      <xsl:copy-of select="description"/>
      <xsl:text>&#xa;</xsl:text>
      <xsl:element name="eco">
        <xsl:attribute name="effdate">
          <xsl:value-of select="effdate"/>
        </xsl:attribute>
        <xsl:value-of select="changeNum"/>
      </xsl:element>
      <xsl:text>&#xa;</xsl:text>
      <xsl:copy-of select="oda"/>
      <xsl:text>&#xa;</xsl:text>
      <xsl:copy-of select="org"/>
      <xsl:text>&#xa;</xsl:text>
    </xsl:element>
  </xsl:template>
  <xsl:template match="document/id"/>
    
</xsl:stylesheet>
and I get this out put
Code:
GE_PART210>



   <document-list>

         <document id="DOC1" revision="-">
         <description xmlns:doc="urn:oid:1.0.10303.28.2.1.3" xmlns:exp="urn:oid:1.0.10303.28.2.1.1"
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">SHEET</description>
         <eco effdate=""/>
         <oda xmlns:doc="urn:oid:1.0.10303.28.2.1.3" xmlns:exp="urn:oid:1.0.10303.28.2.1.1"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">81343</oda>
         <org xmlns:doc="urn:oid:1.0.10303.28.2.1.3" xmlns:exp="urn:oid:1.0.10303.28.2.1.1"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
      </document>
    
      <document id="DOC2" revision="S9 ">
         <description xmlns:doc="urn:oid:1.0.10303.28.2.1.3" xmlns:exp="urn:oid:1.0.10303.28.2.1.1"
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">FASTE</description>
         <eco effdate=""/>
         <oda xmlns:doc="urn:oid:1.0.10303.28.2.1.3" xmlns:exp="urn:oid:1.0.10303.28.2.1.1"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">07482</oda>
         <org xmlns:doc="urn:oid:1.0.10303.28.2.1.3" xmlns:exp="urn:oid:1.0.10303.28.2.1.1"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">CM</org>
      </document>
	
   </document-list>

</GE_PART210>
I thought if I use the
Code:
exclude-result-prefixes="msxsl exp doc xsi"
the namespaces in the output will be excluded, so how is it that I'm still getting them? I have tried this with VS2010 and EditiX 2010 both give me the same output

regards,
ehsan
 
Old November 1st, 2010, 11:34 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Try adding copy-namespaces="no" to your xsl:copy-of instructions.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
ehsansad (November 2nd, 2010)
 
Old November 2nd, 2010, 03:23 AM
Authorized User
 
Join Date: Oct 2010
Posts: 25
Thanks: 8
Thanked 0 Times in 0 Posts
Default

Thanks,
I was wondering if you could explain to me why it didn't work the first time without the copy-namespaces="no"

ehsan
 
Old November 2nd, 2010, 03:36 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Michael says it well here: http://www.stylusstudio.com/xsllist/...post00240.html
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
ehsansad (November 2nd, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
error CS0234: The type or namespace name 'Xml' does not exist in the namespace 'Syste shailesh_kumar C# 2008 aka C# 3.0 8 August 20th, 2009 03:11 AM
Incorrect Namespace output Neal XSLT 1 May 27th, 2009 12:50 PM
Need to convert an existing namespace and add new namespace to the SOAP xml Prabeen XSLT 10 April 28th, 2009 10:18 AM
Namespace Output iceandrews XSLT 1 January 14th, 2009 12:14 PM
Remove namespace from output file jopet25 XSLT 12 March 9th, 2007 11:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.