By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,534 Members | 1,830 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,534 IT Pros & Developers. It's quick & easy.

Could someone help me out with my namespace problems in my XSD

P: n/a
Could someone help me out with the following?

I've got
1)an xml file
2)an xsl
3)a schema

My namespaces are as follow

molecular_db.xml
<database
xmlns="http://www.mine.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mine.com mdb_schema.xsd"

mdb_schema.xsd
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.mine.com"
targetNamespace="http://www.mine.com"
elementFormDefault="qualified">

dB_ss.xsl
<xsl:stylesheet version = "1.0"
xmlns="http://www.mine.com"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"


When I try it out in XMLWriter I keep getting an error that states I
can't use xs:element in the context defined as
xsi:schemaLocation="http://www.mine.com mdb_schema.xsd".

Hence, all I get for output are the headers I defined in the xsl. Take
away the xsd declarations and everything is fine. Better yet, take-away
the xmlns declaration in my xml file and it doesn't look for the xsd and
the file displays fine, headers and data all formatted by the xsl.
What's wrong with my file and how do I fix it?

Jan 20 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a


Mike_August wrote:

My namespaces are as follow

molecular_db.xml
<database
xmlns="http://www.mine.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mine.com mdb_schema.xsd"
>


mdb_schema.xsd
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.mine.com"
targetNamespace="http://www.mine.com"
elementFormDefault="qualified">

dB_ss.xsl
<xsl:stylesheet version = "1.0"
xmlns="http://www.mine.com"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"


If your XSLT stylesheet is supposed to have XPath expressions and match
patterns matching any of the elements in the http://www.mine.com
namespace then you need a prefix e.g.
xmlns:pf="http://www.mine.com"
bound to the namespace URI and then use that prefix e.g.
<xsl:template match="pf:database">
That has to happen in the XSLT stylesheet only so no change to the XML
or schema is needed.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 20 '06 #2

P: n/a
Martin Honnen wrote:


Mike_August wrote:

My namespaces are as follow

molecular_db.xml
<database
xmlns="http://www.mine.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mine.com mdb_schema.xsd"
>


mdb_schema.xsd
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.mine.com"
targetNamespace="http://www.mine.com"
elementFormDefault="qualified">

dB_ss.xsl
<xsl:stylesheet version = "1.0"
xmlns="http://www.mine.com"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

If your XSLT stylesheet is supposed to have XPath expressions and match
patterns matching any of the elements in the http://www.mine.com
namespace then you need a prefix e.g.
xmlns:pf="http://www.mine.com"
bound to the namespace URI and then use that prefix e.g.
<xsl:template match="pf:database">
That has to happen in the XSLT stylesheet only so no change to the XML
or schema is needed.

I'm not using a template. Besides if I change xsl:stylesheet to
xsl:template match="pf:database: and place mlns:pf="http://www.mine.com"
in my database xml file then I just get a 'xsl:stylesheet' does not
match start tag 'xsl:template'. And so this does not solve the problem.

Mike
Jan 20 '06 #3

P: n/a


Mike_August wrote:

I'm not using a template. Besides if I change xsl:stylesheet to
xsl:template match="pf:database: and place mlns:pf="http://www.mine.com"
in my database xml file then I just get a 'xsl:stylesheet' does not
match start tag 'xsl:template'. And so this does not solve the problem.


So your XSLT stylesheet is empty besides the xsl:stylesheet element?
Surely you have
xsl:template
instructions in your XSLT stylesheet? Hmm, indeed you have only
<xsl:template match="/">
but of course I wrote the above as an example and explictly mentioned
XPath expressions and match patterns.
The advice is correct, the stylesheet needs to bind a prefix to the
namespace URI and the XPath expressions need to use that e.g.
<xsl:for-each select="pf:database/pf:molecule">
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 20 '06 #4

P: n/a
Martin Honnen wrote:


Mike_August wrote:

I'm not using a template. Besides if I change xsl:stylesheet to
xsl:template match="pf:database: and place mlns:pf="http://www.mine.com"
in my database xml file then I just get a 'xsl:stylesheet' does not
match start tag 'xsl:template'. And so this does not solve the problem.

So your XSLT stylesheet is empty besides the xsl:stylesheet element?
Surely you have
xsl:template
instructions in your XSLT stylesheet? Hmm, indeed you have only
<xsl:template match="/">
but of course I wrote the above as an example and explictly mentioned
XPath expressions and match patterns.
The advice is correct, the stylesheet needs to bind a prefix to the
namespace URI and the XPath expressions need to use that e.g.
<xsl:for-each select="pf:database/pf:molecule">


Right, did you check your advice on my file? I'll check it out soon. So
I'm supposed to apply the pf namespace for all elements, or just the
for-each tags?
Jan 22 '06 #5

P: n/a


Mike_August wrote:

So
I'm supposed to apply the pf namespace for all elements, or just the
for-each tags?


Any XPath expression to match/select elements in that namespace needs to
have prefix:localname and not simply localname.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 24 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.