"Henning Sprang" <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED]