xsl schema and Namespaces issue

W

william_hulse

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\Bank_Statements_Schema\EXBAEUFRED01.xsl"?>
<FILE>
<GENERAL>
......

</FILE>


- stylesheet1 has namespace declaration as follows

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:eek:utput 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\Bank_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\Bank_Statements_Schema\EXBAEUFRED02.xsl"?>
<FILE>
<GENERAL>
....

</file>


- stylesheet2 has namespace declaration as follows

?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:eek:utput 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"
xmlns:xsi="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_Statements_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"
xmlns:xsi="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_Statements_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 xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.oracle.com/bank_stat.xsd"
xmlns:xdb="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
 
S

Stanimir Stamenkov

/[email protected]/:
- 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\Bank_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\Bank_Statements_Schema\EXBAEUFRED02.xsl"?>
<FILE>
<GENERAL>
...

</file>

I don't see namespace declaration here, neither... plus the
- 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\Bank_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 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:eek:utput 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"
xmlns:xsi="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_Statements_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"
xmlns:xsi="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_Statements_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.
 
W

will

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\Bank_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
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"version="1.0">
<xsl:eek:utput 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"
xmlns:xsi="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_Statements_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"
xmlns:xsi="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_Statements_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 xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.oracle.com/bank_stat.xsd"
xmlns:xdb="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
 
S

Stanimir Stamenkov

/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"
xmlns:xsi="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_Statements_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"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.oracle.com/bank_stat.xsd">
...
</xsl:stylesheet>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top