logo       

Re: xml transformation is removing tags instead of transforming them - mayb: msg#00033

Subject: Re: xml transformation is removing tags instead of transforming them - maybe text encoding problem?
"Henning Sprang" <henning_sprang@xxxxxx> wrote on 2004-02-13 06:55:10 AM:
> While this works perfectly with the first version of my xsl Stylesheets:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <SubscriptionRequest Sender="motivmgr"
> TimeStamp="2004-02-13T12:33:53.509+01:00">
>     <AUSSubscription SubscriptionID="1"
> ValidUntilTimeStamp="2004-02-14T12:33:53.506+01:00">
>         <LineID></LineID>
>         <Hysteresises>5</Hysteresises>
>         <PreviewTime>60</PreviewTime>
>     </AUSSubscription>
> </SubscriptionRequest>
> 
> got perfectly transformed to:

[Correct output removed.  HZ.]

> Now, i've got a new description file, an new java classes, and my input
> looks like this:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <SubscriptionRequest Sender="motivmgr"
>     TimeStamp="2004-02-13T10:47:01.314+01:00" xmlns="vdv454eng">
>     <AUSSubscription SubscriptionID="1"
> ValidUntilTimeStamp="2004-02-14T10:47:01.314+01:00">
>         <LineID></LineID>
>         <Hysteresises>5</Hysteresises>
>         <PreviewTime>60</PreviewTime>
>     </AUSSubscription>
> </SubscriptionRequest>
> 
> but my xsl transformation returns this:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> 
> 
>         5
>         60
> 
> 
> 
> Meaning every tag but the top encoding tag is simply removed but the 
values
> >from inside the tags are still at their exact place.
> 

     The problem is probably due to the declaration of the default 
namespace (xmlns="vdv454eng") in the second document.  In XPath 1.0, a 
path expression like /SubscriptionRequest in your stylesheet only selects 
elements that are no namespace.  In order to select elements that are in a 
namespace (even the default), you must declare a namespace prefix in your 
stylesheet and use that prefix in path expressions.

     The template rules in your stylesheet are probably only trying to 
match names that are in no namespace, and fail to match elements that are 
in your second document.  Instead, the default template rules are ending 
up processing your second document.

     You probably need to decide whether the elements in your document 
need to be in a particular namespace or no namespace, and use that 
consistently.  If you believe that you really do need to match elements 
that have the same local name that might be in no namespace or might be in 
a particular namespace, you have to use expressions like the following:

<xsl:template match="SubscriptionRequest | pre:SubscriptionRequest"
              xmlns:pre="vdv454eng">

or like the following:

<xsl:template match="*[local-name(.) = 'SubscriptionRequest']">


     I hope that helps.

Thanks,

Henry
------------------------------------------------------------------
Henry Zongaro      Xalan development
IBM SWS Toronto Lab   T/L 969-6044;  Phone +1 905 413-6044
mailto:zongaro@xxxxxxxxxx



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
linux.arklinux....    user-groups.lin...    kde.usability/2...    ietf.ipp/2002-0...    mail.spam.spamc...    os.netbsd.devel...    audio.cd-record...    text.unicode.de...    php.documentati...    games.fps.halfl...    window-managers...    suse.oracle.gen...    bug-tracking.gn...    video.dvdrip.us...    xfree86.cvs/200...    java.netbeans.m...    network.argus/2...    culture.sf.kill...    debian.ports.al...    freebsd.questio...    qplus.devel/200...    handhelds.palm....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe