xsl-list
[Top] [All Lists]

Re: How to prevent that XML attributes ares

2006-02-23 02:20:40
Hi Wendell 

In fact, I did try what you suggested before to send the first email to the list

It is not good because it will always delete - for example - the attribute 
isIgnorePagination
And in some of the XML documents, it is set to "true", which is not the default 
value ...

So I need something like : 
        <xsl:template match="@isIgnorePagination='false'"/>
which is not correct, I know this.

Any idea how to write such a condition in a concise way ? 

Jérôme Haguet
Stratégies - France
http://www.cadwin.com

-----Message d'origine-----
Date: Wed, 22 Feb 2006 14:33:53 -0500
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
From: Wendell Piez <wapiez(_at_)mulberrytech(_dot_)com>
Subject: Re: [xsl] How to prevent that XML attributes ares
  automatically added ? 
Message-Id: 
<7(_dot_)0(_dot_)0(_dot_)16(_dot_)0(_dot_)20060222142600(_dot_)037a23e8(_at_)mulberrytech(_dot_)com>

Hi Jerome,

At 12:36 PM 2/22/2006, you wrote:
Basically, it works.

Except one thing : in some cases, it adds some attributes to some 
XML elements.
I guess that this happens in order that the final XML become 
compliant with the DTD specified in the top of the source XML file.
If I delete the DTD directive, no attributes are added.

You are almost half right. This is not happening so that the result 
be valid to the source's DTD. Most of the time that would be a bad 
idea and undesirable.

Rather, you are apparently doing a near-identity transformation, in 
which most of what the stylesheet is doing is simply copying the 
input to the result. But your DTD contains attribute declarations 
that provide default values to some of the attributes in your 
document. Accordingly, when your DOCTYPE declaration is in place, the 
parsed document (the tree-shaped thing on which the transform 
actually operates) contains the attributes -- which then get copied 
along with the rest.

If you want these not to be there, simply write your stylesheet to 
suppress them instead of copying them.

Depending on how your identity transformation is constructed, this 
can be as easy as:

<xsl:template
   match="@isFloatColumnFooter | @whenResourceMissingType | 
@isIgnorePagination"/>

Alternatively, ensure that the DTD is not used by removing or 
commenting out the DOCTYPE declarations in your input; as you've 
found, the defaulted attributes won't then be copied to the result. 
But the first solution is less of a hack.

Cheers,
Wendell


Here above is an example of the added attributes :

<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report 
Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd";>
<jasperReport ...isFloatColumnFooter="false" 
whenResourceMissingType="Null" isIgnorePagination="false">
...
</jasperReport>

======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================



--~------------------------------------------------------------------
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>