You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by Zealot <ze...@gmail.com> on 2006/08/31 19:41:21 UTC

xalan can not copy namespace prefix when using schema

this is my test.xml

<?xml version="1.0"?>
<ns:root xmlns:ns="something"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="something test.xsd"
/>

and test.xsd

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
         targetNamespace="something"
         xmlns:ns="something">

         <complexType name="root" />

         <element name="root" type="ns:root" />
</schema>

test.xslt

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         xmlns:ns="something">
         <xsl:output method="xml" />
         <xsl:template match="ns:root">
                 <xsl:copy />
         </xsl:template>
</xsl:stylesheet>

use:

$ xalan -validate -xsl test.xslt -in test.xml

I got

<?xml version="1.0" encoding="UTF-8"?><root xmlns:ns="something" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

but I expect root element with "ns" namespace prefix.
After deleting schema information in test.xml, it works well. I got :

<?xml version="1.0" encoding="UTF-8"?><ns:root xmlns:ns="something"/>

Is it a xalan bug ?

My xalan version:
$ xalan -v

Xalan version 1.10.0
Xerces version 2.7.0


Re: xalan can not copy namespace prefix when using schema

Posted by David Bertoni <db...@apache.org>.
David Bertoni wrote:
> Zealot wrote:
>> this is my test.xml
>>
...
>>
>> Is it a xalan bug ?
> 
> Definitely, although something very strange must be going on.

OK, it turns out this is a bug in Xerces-C, because it's delivering bogus 
SAX2 events.

> 
> Can you please create a Jira issue and attach copies of the files?

Please don't create a Jira issue for Xalan-C.  Instead, you can get the 
latest Xerces-C from the SVN repository to get the fix.  Make sure you get 
the 2.7 branch, rather than the 3.0 branch.

Thanks!

Dave

Re: xalan can not copy namespace prefix when using schema

Posted by David Bertoni <db...@apache.org>.
Zealot wrote:
> this is my test.xml
> 
> <?xml version="1.0"?>
> <ns:root xmlns:ns="something"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         xsi:schemaLocation="something test.xsd"
> />
> 
> and test.xsd
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
>         targetNamespace="something"
>         xmlns:ns="something">
> 
>         <complexType name="root" />
> 
>         <element name="root" type="ns:root" />
> </schema>
> 
> test.xslt
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
>         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>         xmlns:ns="something">
>         <xsl:output method="xml" />
>         <xsl:template match="ns:root">
>                 <xsl:copy />
>         </xsl:template>
> </xsl:stylesheet>
> 
> use:
> 
> $ xalan -validate -xsl test.xslt -in test.xml
> 
> I got
> 
> <?xml version="1.0" encoding="UTF-8"?><root xmlns:ns="something" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
> 
> but I expect root element with "ns" namespace prefix.
> After deleting schema information in test.xml, it works well. I got :
> 
> <?xml version="1.0" encoding="UTF-8"?><ns:root xmlns:ns="something"/>
> 
> Is it a xalan bug ?

Definitely, although something very strange must be going on.

Can you please create a Jira issue and attach copies of the files?

     http://issues.apache.org/jira/browse/XALANC

I will try to take a look at this in the next couple of days.

Thanks!

Dave