XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Simon TemplarSubject: Duplicate xmlns value and XML header problem
Author: Simon Templar
Date: 31 Aug 2005 10:11 AM
Hi,
I am using the follwing XSL to generate a XML file:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://www.fsa.gov.uk/XMLSchema/FSAHSFFeedRI-v1-2">
<xsl:template match="/">
<FSAHSFFeedRI xmlns="http://www.fsa.gov.uk/XMLSchema/FSAHSFFeedRI-v1-2">
... and so on.

And here's a snippet of what the output looks like:

<?xml version="1.0"?>
<FSAHSFFeedRI xmlns="http://www.fsa.gov.uk/XMLSchema/FSAHSFFeedRI-v1-2" xmlns:a="http://www.fsa.gov.uk/XMLSchema/FSAHSFFeedRI-v1-2">

Note that there's no 'encoding="utf-8"' in the 1st line. And in the second line there's xmlns:a="http://.....">

Below is what I want the above part to look like:

<?xml version="1.0" encoding="utf-8" ?>
<FSAHSFFeedPP xmlns="http://www.fsa.gov.uk/XMLSchema/FSAHSFFeedPP-v1-2">

What do I need to change in my XSL to achieve the above? I have tried to manually remove xmlns:a... part but the file fails to validate after that. And even though the XSL contains the encoding bit but the XML file fails to get that.

Any help is appreciated.

Regards.

Postnext
Tony LavinioSubject: Duplicate xmlns value and XML header problem
Author: Tony Lavinio
Date: 31 Aug 2005 11:14 PM
The <?xml... encoding=?> in the XSLT file refers to the encoding of the
XSLT file itself, not of its output. Use <xsl:output encoding="utf-8"/>
right inside of your <xsl:stylesheet> directive.

As for getting rid of the duplication between xmlns and xmlns:a, if they
both point to the same namespace, then not only do you have to get rid of
the xmlns:a= attribute, but also anywhere in the document that an element
or attribute is prefixed by a:, you must remove the a: also.

Postnext
Simon TemplarSubject: Duplicate xmlns value and XML header problem
Author: Simon Templar
Date: 05 Sep 2005 07:10 AM
>The <?xml... encoding=?>
>in the XSLT file refers to the
>encoding of the
>XSLT file itself, not of its
>output. Use <xsl:output
>encoding="utf-8"/>
>right inside of your
><xsl:stylesheet>
>directive.

Thanks Tony, I'll use the parameter as suggested.

>As for getting rid of the
>duplication between xmlns and
>xmlns:a, if they
>both point to the same
>namespace, then not only do
>you have to get rid of
>the xmlns:a= attribute, but
>also anywhere in the document
>that an element
>or attribute is prefixed by
>a:, you must remove the a:
>also.

Although they both point to the same schema, the point is that the following line is already present in the source XML file :
<FSAHSFFeedPP xmlns="http://www.fsa.gov.uk/XMLSchema/FSAHSFFeedPP-v1-2">
and the xmlns:a is inserted by Stylus Studio when the stylesheet is created using XSLT Mapper. If I remove it then the stylesheet won't create a valid XML file. Hence my problem still remains. I hope I explained it correctly.

Below is what I would want the above part in output XML file to look like:

<?xml version="1.0" encoding="utf-8" ?>
<FSAHSFFeedPP xmlns="http://www.fsa.gov.uk/XMLSchema/FSAHSFFeedPP-v1-2">

Regards.

Postnext
Tony LavinioSubject: Duplicate xmlns value and XML header problem
Author: Tony Lavinio
Date: 06 Sep 2005 09:43 AM
There isn't enough information in your post to give an answer;
if you could either attach the input .xml and .xslt files here
(using the little "Attach File" checkbox in the reply window),
or email them to stylus-field-report (at) stylusstudio.com, we'd
be happy to take a look for you.

Postnext
Simon TemplarSubject: Duplicate xmlns value and XML header problem
Author: Simon Templar
Date: 06 Sep 2005 10:44 AM
>There isn't enough information
>in your post to give an
>answer;
>if you could either attach the
>input .xml and .xslt files
>here
>(using the little "Attach
>File" checkbox in the reply
>window),
>or email them to
>stylus-field-report (at)
>stylusstudio.com, we'd
>be happy to take a look for
>you.
Thanks Tony. I am attaching the files (source XML and XSLT used to transform it).


DocumentPQMKUP19.xml
Source XML

DocumentPP.xsl
XSLT for source file.

Postnext
Tony LavinioSubject: Duplicate xmlns value and XML header problem
Author: Tony Lavinio
Date: 06 Sep 2005 05:17 PM
Sorry, I also should have asked for the schema, so we can see what
you are mapping against!

Postnext
Simon TemplarSubject: Duplicate xmlns value and XML header problem
Author: Simon Templar
Date: 07 Sep 2005 03:46 AM
>Sorry, I also should have
>asked for the schema, so we
>can see what
>you are mapping against!
Ahhh...! Here's the schema.


DocumentFSAHSFFeedPP-v1-2.xsd
PP Schema

DocumentFSAFeedCommon-v1-2(1).xsd
Common Items schema

Postnext
Tony LavinioSubject: Duplicate xmlns value and XML header problem
Author: Tony Lavinio
Date: 08 Sep 2005 10:19 AM
Okay, I asked the person responsible for this, and his answer is that
there is a problem in the mapper that shows up in your case. That's
the bad news.

The good news is that there is a work-around, and also that someone will
fix this ASAP.

The workaround is to use an instance XML document as a target, instead
of the schema. If you have a sample of what the output should look like,
that will make mapper happy. For some reason, mapper has decided to not
like the namespaces in the schema.

Postnext
Simon TemplarSubject: Duplicate xmlns value and XML header problem
Author: Simon Templar
Date: 09 Sep 2005 05:25 AM
>Okay, I asked the person
>responsible for this, and his
>answer is that
>there is a problem in the
>mapper that shows up in your
>case. That's
>the bad news.
>
>The good news is that there is
>a work-around, and also that
>someone will
>fix this ASAP.
>
>The workaround is to use an
>instance XML document as a
>target, instead
>of the schema. If you have a
>sample of what the output
>should look like,
>that will make mapper happy.
>For some reason, mapper has
>decided to not
>like the namespaces in the
>schema.
Many thanks for looking into the matter, Tony. However I am still having the same problem using the suggested workaround. I am attaching the input, output (used to generate the XSLT) and XSLT file that I used.


DocumentPQMKUP16G21.xml
Input file

DocumentCISPP_valid_Debug.xml
Output file used instead of Schema.

DocumentCISPP_Debug.xsl
XSLT generated using Mapper.

Postnext
Minollo I.Subject: Duplicate xmlns value and XML header problem
Author: Minollo I.
Date: 09 Sep 2005 08:55 AM
Simon,
I took a look at your latest mapping, and it looks like there is something wrong. Your source XML document is:

<FSAHSFFeedRI xmlns="http://www.fsa.gov.uk/XMLSchema/FSAHSFFeedRI-v1-2">
<FSAFeedHeader>
<FeedTargetSchemaVersion>1.2</FeedTargetSchemaVersion>
<Submitter>
...

...but your XSLT is doing:
<xsl:template match="/">
<FSAHSFFeedPP xmlns="http://www.fsa.gov.uk/XMLSchema/FSAHSFFeedPP-v1-2">
<FSAFeedHeader xmlns="http://www.fsa.gov.uk/XMLSchema/FSAFeedCommon-v1-2">
<FeedTargetSchemaVersion>
<xsl:value-of select="a:FSAHSFFeedPP/a:FSAFeedHeader/a:FeedTargetSchemaVersion"/>
...

...which means that it won't be able to match the source in the value-of it's using.

Creating a mapping from scratch that use the XML source and target you attached, things seem to work OK from what I can understand, even if there is some redundancy in namespace declarations:
<xsl:template match="/">
<a:FSAHSFFeedPP xmlns="http://www.fsa.gov.uk/XMLSchema/FSAHSFFeedPP-v1-2">
<b:FSAFeedHeader xmlns="http://www.fsa.gov.uk/XMLSchema/FSAFeedCommon-v1-2">
<xsl:value-of select="c:FSAHSFFeedRI/c:FSAFeedHeader"/>
<b:FeedTargetSchemaVersion>
<xsl:value-of select="c:FSAHSFFeedRI/c:FSAFeedHeader/c:FeedTargetSchemaVersion"/>
...

Minollo

Postnext
Simon TemplarSubject: Duplicate xmlns value and XML header problem
Author: Simon Templar
Date: 10 Sep 2005 09:41 AM
>Creating a mapping from
>scratch that use the XML
>source and target you
>attached, things seem to work
>OK from what I can understand,
>even if there is some
>redundancy in namespace
>declarations:

Minollo,
Thanks for replying. You are right that despite the namespace duplication Stylus Studio still produces a valid XML. But that is my point. As we have to adhere to a specification set by a third-party having a duplicate namespace declaration can be a potential problem and that is what I was trying to point to in my posts. From what I understood reading Tony's last post was that he meant using the proposed workaround I'll be able to get rid of the namespace duplication, which didn't work for me. The output XML should look exactly like the output file I have uploaded in my previous post. I am attaching the screenshot of the XSLT Mapper that I have developed to give an idea of what I am doing. Hope that explains it better.

Regards.


ImageXSLTMapperscreenshot.PNG

Postnext
Simon TemplarSubject: Duplicate xmlns value and XML header problem
Author: Simon Templar
Date: 14 Sep 2005 11:30 AM
Hi,
Is there any update regarding the update that Tony was referring to? I'd appreciate any feedback.

Regards.

Postnext
Tony LavinioSubject: Duplicate xmlns value and XML header problem
Author: Tony Lavinio
Date: 14 Sep 2005 12:09 PM
The patch 377n will be released on 9/19.

But we are a little confused by something. Any XML-aware application
should treat <peppo xmlns="pippo"/> and <p:peppo xmlns:p="pippo"/>
exactly the same. What prefix is used, or whether it is the default
namespace or an explicit one, shouldn't make any difference to the
consumer. In fact, they aren't supposed to.

So what exactly is wrong in this case, since the forms as far as the
XML infoset are concerned, are identical?

In some cases, due to scoping, the mapper may generate namespace
prefixes where someone coding by hand wouldn't, or vice-versa.

Postnext
Simon TemplarSubject: Duplicate xmlns value and XML header problem
Author: Simon Templar
Date: 16 Sep 2005 05:19 AM
Originally Posted: 16 Sep 2005 05:20 AM
>The patch 377n will be
>released on 9/19.

Thanks for the update Tony.

>But we are a little confused
>by something. Any XML-aware
>application
>should treat <peppo
>xmlns="pippo"/> and
><p:peppo
>xmlns:p="pippo"/>
>exactly the same. What prefix
>is used, or whether it is the
>default
>namespace or an explicit one,
>shouldn't make any difference
>to the
>consumer. In fact, they
>aren't supposed to.
>
>So what exactly is wrong in
>this case, since the forms as
>far as the
>XML infoset are concerned, are
>identical?

I tested the files with duplicate namespace with the third-party server and they were accepted without any problems. You are right in saying that technically there shouldn't be a problem. The minor hitch is with the Production Support people in my company who say that the final format of the output doesn't "exactly" match the specifications although I've tried to make them aware of the fact that the files are valid and accepted by the third-party. Hence, the slightly pressing need for an "exact" output file. Also XML is very new technology in my company so everyone related to the project are still picking up XML slowly.

>In some cases, due to scoping,
>the mapper may generate
>namespace
>prefixes where someone coding
>by hand wouldn't, or
>vice-versa.


Thanks for your help.

Regards.

Postnext
Tony LavinioSubject: Duplicate xmlns value and XML header problem
Author: Tony Lavinio
Date: 16 Sep 2005 02:43 PM
> Hence, the slightly pressing need for an "exact" output file.
> Also XML is very new technology in my company so everyone
> related to the project are still picking up XML slowly.

There are bound to be other surprises then also. For example, the
order of attributes doesn't matter, and certain white space can be
ignored. And " or ' can be used for quotes. And empty elements have
a shorthand form. So

<abc def = "hello" ghi="goodbye" ></abc >

is "identical" to

<abc ghi='goodbye' def='hello'/>

Postnext
Simon TemplarSubject: Duplicate xmlns value and XML header problem
Author: Simon Templar
Date: 19 Sep 2005 12:42 PM
Thanks for the input Tony. In my case we've already acheived the correct order of appearance of tags apart from the duplicate xmlns 'issue' that still persists after updating Stylus to the latest Build (377n).

Also, I have downloaded in installed the latest Build but I still can't get rid of the duplicate namespace. Apart from that now the prefixes are automatically prefixed to the tags which has created an additional step of removing those manually. And because I am using a common schema now that is also added in addition to the original one.

Unless I am using the XSLT mapper completely wrong I can't figure out a way to get my output file in the desired format. I'd request someone to please create an XSLT that'll get the results that I am trying to achieve. If that's just how the product funtions then I just have to accept it and move on. I am attaching the following files:



DocumentPP_Input.xml
Input File

DocumentPP_Output.xml
Output File

DocumentFSAHSFFeedPP-v1-2(1).xsd
PP Schema

DocumentFSAFeedCommon-v1-2(2).xsd
Common Schema

Posttop
Simon TemplarSubject: Duplicate xmlns value and XML header problem
Author: Simon Templar
Date: 21 Sep 2005 03:10 AM
Ok! Got an idea from reading another post and sorted the problem by adding exclude-result-prefixes="a" as follows:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://www.fsa.gov.uk/XMLSchema/FSAHSFFeedPP-v1-2" exclude-result-prefixes="a">

Thanks to all the support people.

Regards.

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.