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

Re: AW: AW: exclude result prefixes doesn't stop prefi

Subject: Re: AW: AW: exclude result prefixes doesn't stop prefix fromshowingup.
From: "Mark R. Diggory" <mdiggory@xxxxxxxxxxxxxxxxx>
Date: Fri, 22 Aug 2003 18:35:17 -0400
exclude result prefixes
True,

I now understand we talking about the implementation in terms of how a particular transformer will handle the serialization of the result tree. I my case it gets dumped to a j.x.t.s.StreamResult and I understand the implementation of this is not neccessarily under any restriction by the xslt spec. I've found that Xalan gives me what I need in this case, so I'll be using it for this particular transform process.

Strange that Saxon on Windows would behave different than Saxon on Linux. Are you using Xerces as the parser? Does Saxon somehow differ to the XML parser for StreamResult content normalization etc? Maybe your using a different parser in this case?

Cheers and thanks,
Mark

Markus Abt wrote:

Mark,

with Saxon 6.5.2 on Java 1.4.0 on Windows I get:

<?xml version="1.0" encoding="utf-8"?>
<codeBook xmlns="http://www.icpsr.umich.edu/DDI">
   <docDscr>
      <citation>
         <titlStmt>
            <titl/>
         </titlStmt>
      </citation>
   </docDscr>
   <stdyDscr/>
</codeBook>

This happens to be implementation dependant as it is not a problem
of the xslt transformation, but of the serialization.

Maybe putting the namespace declaration on the docDsrc node
changes the output in your case, but as the FAQ states you have no
real control over it...

Markus
__________________________
Markus Abt
Comet Computer GmbH
http://www.comet.de



----------
Von: 	Mark R. Diggory
Gesendet: 	Freitag, 22. August 2003 19:22
An: 	xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Betreff: 	Re: AW:  exclude result prefixes doesn't stop prefix from showingup.

Thanks for the idea, but it didn't change the behavior, the result still looks like this:

<?xml version="1.0" encoding="utf-8"?>
<codeBook xmlns="http://www.icpsr.umich.edu/DDI">
    <docDscr xmlns:ddi="http://www.icpsr.umich.edu/DDI">
        <citation>
            <titlStmt>...

Markus Abt wrote:


Mark, try to put the namespace node at the root element of the result,
not at xsl:stylesheet:


<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet
	version="1.0"
	xmlns:ddi="http://www.icpsr.umich.edu/DDI"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	>
	<xsl:template match="ddi:codeBook">
	   <xsl:copy xmlns="http://www.icpsr.umich.edu/DDI">
	     <xsl:apply-templates select="@*"/>
		<docDscr>
		   <citation>
			<titlStmt>
			   <titl>
			     <xsl:value-of select="ddi:stdyDscr/ddi:citation/ddi:titlStmt/ddi:titl"/>
			   </titl>
			</titlStmt>
		    </citation>
	         </docDscr>	
		 <xsl:apply-templates select="*"/>
		</xsl:copy>
	</xsl:template>
</xsl:stylesheet>


Regards, Markus __________________________ Markus Abt Comet Computer GmbH http://www.comet.de



----------
Von: 	Mark R. Diggory
Gesendet: 	Freitag, 22. August 2003 17:33
An: 	xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Betreff: 	Re:  exclude result prefixes doesn't stop prefix from showingup.

I did see that particular Q/A in the XSL FAQ and in your book, I agree it works, but I feel like its a bit of an overkill

Initially I had tried to write the stylesheet using the DDI namespace as the default namespace, like below. but this failed to detect the default namespace in the source document so none of the source elements were properly matched. I thought to myself, there should be some way I can match the default namespace in the source document? But I can't find anything that does this. I came across the #default entity, but this doesn't seem to fit either.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
    version="1.0"
    xmlns="http://www.icpsr.umich.edu/DDI"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    exclude-result-prefixes="ddi"
    >
    <xsl:template match="codeBook">
       <xsl:copy>
         <xsl:apply-templates select="@*"/>
        <docDscr>
           ...
               <titl>
                 <xsl:value-of select="stdyDscr/citation/titlStmt/titl"/>
               </titl>
           ...
         </docDscr>
         <xsl:apply-templates select="*"/>
        </xsl:copy>
    </xsl:template>

    ...
</xsl:stylesheet>

Michael Kay wrote:


exclude-result-prefixes only affects the namespaces copied from the
stylesheet by a literal result element, it doesn't affect copying of
namespaces from source documents. In any case, the codeBook element is
in the namespace http://www.icpsr.umich.edu/DDI, so the namespace must
be declared. exclude-result-prefixes only suppresses namespaces that are
not used in any element or attribute name, and this namespace is used.
What you want to do is not to suppress the namespace declaration, it is
to change the name of the element, which you can do by using
<xsl:element name="{local-name(.)}"> in place of xsl:copy.

Michael Kay




-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Mark R. Diggory
Sent: 21 August 2003 23:10
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: exclude result prefixes doesn't stop prefix

from showing up.


I have a stylesheet that copies an xml document with a default namespace while it also is adding some content to it:

*The stylesheet*

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
	version="1.0"
	xmlns="http://www.icpsr.umich.edu/DDI"
	xmlns:ddi="http://www.icpsr.umich.edu/DDI"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	exclude-result-prefixes="ddi"
	>

<xsl:template match="@* | *">
<xsl:copy>
<xsl:apply-templates select="* | @* | text()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="ddi:codeBook">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<docDscr>
<citation>
<titlStmt>
<titl>
<xsl:value-of select="ddi:stdyDscr/ddi:citation/ddi:titlStmt/ddi:titl"/>
</titl>
</titlStmt>
</citation>
</docDscr>
<xsl:apply-templates select="*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>


*The xml document*

<?xml version="1.0" encoding="utf-8"?>
<codeBook xmlns="http://www.icpsr.umich.edu/DDI" >
	<stdyDscr> ....


*the resulting xml document*



<?xml version="1.0" encoding="utf-8"?> <codeBook xmlns="http://www.icpsr.umich.edu/DDI"> <docDscr xmlns:ddi="http://www.icpsr.umich.edu/DDI"> <citation> ... </citation> </docDscr> <stdyDscr> <citation> <titlStmt> <titl>Foo bar</titl> </titlStmt> </citation> </stdyDscr> </codeBook>

My problem is that I'm getting an extra xmlns:ddi="http://www.icpsr.umich.edu/DDI" in the docDscr element even though I'm suppressing it in the excludes. Is there any way I can stop this from happening?

-Mark Diggory
Harvard MIT Data Center



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list





XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


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.