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

Discussion in 'XML' started by Mike_August, Jan 20, 2006.

  1. Mike_August

    Mike_August Guest

    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?
    Mike_August, Jan 20, 2006
    #1
    1. Advertising

  2. 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/
    Martin Honnen, Jan 20, 2006
    #2
    1. Advertising

  3. Mike_August

    Mike_August Guest

    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
    Mike_August, Jan 20, 2006
    #3
  4. 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/
    Martin Honnen, Jan 20, 2006
    #4
  5. Mike_August

    Mike_August Guest

    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?
    Mike_August, Jan 22, 2006
    #5
  6. 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/
    Martin Honnen, Jan 24, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Curious

    If Someone Could Help, Please?

    Curious, Apr 17, 2004, in forum: HTML
    Replies:
    2
    Views:
    307
    Whitecrest
    Apr 17, 2004
  2. Burak
    Replies:
    0
    Views:
    573
    Burak
    Jul 1, 2004
  3. 1111111111
    Replies:
    11
    Views:
    574
    Aguilar, James
    Jul 12, 2004
  4. Replies:
    3
    Views:
    2,188
    Stephen Slyman
    Jun 9, 2006
  5. shapper
    Replies:
    0
    Views:
    340
    shapper
    Dec 18, 2007
Loading...

Share This Page