Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > xsl schema and Namespaces issue

Reply
Thread Tools

xsl schema and Namespaces issue

 
 
william_hulse@hotmail.com
Guest
Posts: n/a
 
      01-28-2005
The general process i am currently working on is this:


STEP 1 xml doc1 is transformed using stylesheet1 to produce xml doc2

- xml doc1 has a namespace declaration as follows...

<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<?xml-stylesheet type="text/xsl"
href="G:\Working\User\Will_Hulse\NEW\xmldb\code\Ba nk_Statements_Schema\EXBAEUFRED01.xsl"?>
<FILE>
<GENERAL>
......

</FILE>


- stylesheet1 has namespace declaration as follows

<?xml version="1.0"?>
<xsl:stylesheet xmlnssl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput indent="yes"/>

....

</xsl:stylesheet>

- the result has namespace as follows


<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"
href="G:\Working\User\Will_Hulse\NEW\xmldb\code\Ba nk_Statements_Schema\EXBAEUFRED02.xsl"?>
<FILE>
<GENERAL>
....

</file>

.... which is fine

STEP 2 - xml doc2 is transformed using stylesheet2 to produce xml doc3
which must conform to an xml schema

- xml doc2 has namespace as follows

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"
href="G:\Working\User\Will_Hulse\NEW\xmldb\code\Ba nk_Statements_Schema\EXBAEUFRED02.xsl"?>
<FILE>
<GENERAL>
....

</file>


- stylesheet2 has namespace declaration as follows

?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlnssl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput method="xml" omit-xml-declaration="no" indent="yes"/>

- but also has the following clause to insert namespace info into
resulting document, 'linking' it to a schema bank_stat.xsd

<FILE xmlns="http://www.oracle.com/bank_stat.xsd"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.oracle.com/bank_stat.xsd
G:\Working\User\Will_Hulse\NEW\xmldb\code\Bank_Sta tements_Schema\BANK_STAT.xsd">
<xsl:apply-templates select="BANK_STATEMENTS"/>
</FILE>



The result however contains the following with a bogus empty namespace
declaration in BANK_STATEMENTS

<?xml version="1.0" encoding="UTF-8"?>
<FILE xmlns="http://www.oracle.com/bank_stat.xsd"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.oracle.com/bank_stat.xsd
G:\Working\User\Will_Hulse\NEW\xmldb\code\Bank_Sta tements_Schema\BANK_STAT.xsd">
<BANK_STATEMENTS xmlns="">
<GENERAL>
<FILENAME>EUBAEUFRED01.XML</FILENAME>
.....



-- the namespace of the schema is as follows

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlnss="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.oracle.com/bank_stat.xsd"
xmlnsdb="http://xmlns.oracle.com/xdb"
targetNamespace="http://www.oracle.com/bank_stat.xsd"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="FILE">
<xs:complexType>



Questions..

- Why does the bank statements tag contain xmlns="" and how can we stop
it happening?

- Is there a better way to insert schema referencing into the result of
an xsl transform?

- How does the schema namespace attributes elementFormDefault and
attributeFormDefault play a part in this...
making the value of elementFormDefault = "unqualified" in the schema
makes the xml fail validation. If we
then remove the bogus xmlns="" from the doc, it then passes
validation..


Any help with the above would be greatly appreciated...
Regards

Will

 
Reply With Quote
 
 
 
 
Stanimir Stamenkov
Guest
Posts: n/a
 
      01-28-2005
//:

> - xml doc1 has a namespace declaration as follows...
>
> <?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
> <?xml-stylesheet type="text/xsl"
> href="G:\Working\User\Will_Hulse\NEW\xmldb\code\Ba nk_Statements_Schema\EXBAEUFRED01.xsl"?>
> <FILE>
> <GENERAL>
> .....
>
> </FILE>


Where's the namespace declaration?

[...]
> - the result has namespace as follows
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-stylesheet type="text/xsl"
> href="G:\Working\User\Will_Hulse\NEW\xmldb\code\Ba nk_Statements_Schema\EXBAEUFRED02.xsl"?>
> <FILE>
> <GENERAL>
> ...
>
> </file>


I don't see namespace declaration here, neither... plus the
<FILE>...</file> is not well-formed.

> - xml doc2 has namespace as follows
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-stylesheet type="text/xsl"
> href="G:\Working\User\Will_Hulse\NEW\xmldb\code\Ba nk_Statements_Schema\EXBAEUFRED02.xsl"?>
> <FILE>
> <GENERAL>
> ...
>
> </file>


Man, where do you see those namespace declarations!?

> - stylesheet2 has namespace declaration as follows
>
> ?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet xmlnssl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xslutput method="xml" omit-xml-declaration="no" indent="yes"/>
>
> - but also has the following clause to insert namespace info into
> resulting document, 'linking' it to a schema bank_stat.xsd


Where's the "clause" to insert that (following) namespace info?

> <FILE xmlns="http://www.oracle.com/bank_stat.xsd"
> xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.oracle.com/bank_stat.xsd
> G:\Working\User\Will_Hulse\NEW\xmldb\code\Bank_Sta tements_Schema\BANK_STAT.xsd">
> <xsl:apply-templates select="BANK_STATEMENTS"/>
> </FILE>
>
> The result however contains the following with a bogus empty namespace
> declaration in BANK_STATEMENTS
>
> <?xml version="1.0" encoding="UTF-8"?>
> <FILE xmlns="http://www.oracle.com/bank_stat.xsd"
> xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.oracle.com/bank_stat.xsd
> G:\Working\User\Will_Hulse\NEW\xmldb\code\Bank_Sta tements_Schema\BANK_STAT.xsd">
> <BANK_STATEMENTS xmlns="">
> <GENERAL>
> <FILENAME>EUBAEUFRED01.XML</FILENAME>
> ....

[...]
> Questions..
>
> - Why does the bank statements tag contain xmlns="" and how can we stop
> it happening?


I didn't see any default namespace declarations in your stylesheets
(or in what you've shown), but then it shouldn't need to output a
default nonamespace declaration if it is the root of your document,
I think.

> - Is there a better way to insert schema referencing into the result of
> an xsl transform?


You didn't show how do you do it, currently.

> - How does the schema namespace attributes elementFormDefault and
> attributeFormDefault play a part in this...
> making the value of elementFormDefault = "unqualified" in the schema
> makes the xml fail validation. If we
> then remove the bogus xmlns="" from the doc, it then passes
> validation..


Too many questions - define more precise issues/topics and post
questions separately. Post or preferably point URLs to complete
examples you're trying with and which demonstrate your problem.

--
Stanimir
 
Reply With Quote
 
 
 
 
will
Guest
Posts: n/a
 
      01-29-2005
Apologies for some of this i was in a rush to get out of the office...

Anyway some additional info..

We can ignore STEP 1 as it works fine

STEP 2 The xml is then transformed using a second xsl to produce a
final xml
which must conform to an xml schema

- xml has no explicit namespace declaration as follows..

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"
href="G:\Working\User\Will_Hulse\NEW\xmldb\code\Ba nk_Stateme*nts_Schema\EXBAEUFRED02.xsl"?>

<FILE>
<GENERAL>
....
</FILE>

- stylesheet2 has again standard xsl namespace declaration as follows

?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
xmlnssl="http://www.w3.org/1999/XSL/Transform"version="1.0">
<xslutput method="xml" omit-xml-declaration="no" indent="y*es"/>

- but also contains the following fragment to create a FILE element
that includes namespace info, 'linking' it to a schema bank_stat.xsd

<FILE xmlns="http://www.oracle.com/bank_stat.xsd"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.oracle.com/bank_stat.xsd

G:\Working\User\Will_Hulse\NEW\xmldb\code\Bank_Sta tements_Sc*hema\BANK_STAT.xsd">

<xsl:apply-templates select="BANK_STATEMENTS"/>
</FILE>

- The result from the above transformation however contains the
following fragment with a bogus empty namespace declaration ie
<BANK_STATEMENTS xmlns="">

<?xml version="1.0" encoding="UTF-8"?>
<FILE xmlns="http://www.oracle.com/bank_stat.xsd"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.oracle.com/bank_stat.xsd

G:\Working\User\Will_Hulse\NEW\xmldb\code\Bank_Sta tements_Sc*hema\BANK_STAT.xsd">

<BANK_STATEMENTS xmlns="">
<GENERAL>
<FILENAME>EUBAEUFRED01.XML</FILENAME>
.....

- the namespace declaration of the schema the above xml has to conform
to is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlnss="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.oracle.com/bank_stat.xsd"
xmlnsdb="http://xmlns.oracle.com/xdb"targetNamespace="http://www.oracle.com/bank_stat.xsd"

elementFormDefault="qualified" attributeFormDefault="unquali*fied">
<xs:element name="FILE">
<xs:complexType>

Questions..


1 - Why does the bank statements tag contain xmlns="" and how can we
stop it happening?
2 - Is there a better way to insert schema referencing into the result
of an xsl transform?
3 - How does the schema namespace attributes elementFormDefault and
attributeFormDefault play a part in this...
making the value of elementFormDefault = "unqualified" in the schema
makes the xml fail validation. If we
then remove the bogus xmlns="" from the doc, it then passes
validation..


Any help with the above would be greatly appreciated...
Regards

Will

 
Reply With Quote
 
Stanimir Stamenkov
Guest
Posts: n/a
 
      01-29-2005
/will/:

> - but also contains the following fragment to create a FILE element
> that includes namespace info, 'linking' it to a schema bank_stat.xsd
>
> <FILE xmlns="http://www.oracle.com/bank_stat.xsd"
> xmlnssi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.oracle.com/bank_stat.xsd
>
> G:\Working\User\Will_Hulse\NEW\xmldb\code\Bank_Sta tements_Sc*hema\BANK_STAT.xsd">
>
> <xsl:apply-templates select="BANK_STATEMENTS"/>
> </FILE>
>
> - The result from the above transformation however contains the
> following fragment with a bogus empty namespace declaration ie
> <BANK_STATEMENTS xmlns="">


Again, it is hard to guess from the partial messy sources you're
posting - next time just put complete examples (which need not to be
the originals if they contain sensitive information), which
demonstrate your problem, on the web and point to them. Either way
you're throwing away your chances somebody would have a look at your
problem.

Anyway, probably the "BANK_STATEMENTS" element is not descendant of
the "FILE" element (where you declare the default namespace) in the
stylesheet, so it effectively doesn't have a namespace - that's why
the generated xmlns="" appears (because in the generated structure
the "BANK_STATEMENTS" is descendant of the "FILE"). You should
declare the default namespace at the root stylesheet element:

<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.oracle.com/bank_stat.xsd">
...
</xsl:stylesheet>

--
Stanimir
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
web.xml / XML schema issue, why do some XML schema attributes disappear asciz@starmail.com Java 3 02-20-2007 09:56 AM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
DTDs, schema's and namespaces Miel Bronneberg XML 2 09-30-2003 05:34 PM
namespaces and <xsl:value-of> Rainer Herbst XML 3 09-30-2003 06:16 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57