Referencing XSD Schema in XSLT

Discussion in 'XML' started by Vijay, Oct 31, 2005.

  1. Vijay

    Vijay Guest

    I had a following xslt :

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:xsl="http://www.w3.org/1999/XSL/Format" >


    </xsl:stylesheet>

    and then I referenced a XSD in xsl:stylesheet element as follows :

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:xsl="http://www.w3.org/1999/XSL/Format"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.w3.org/1999/XSL/Format
    C:\FOP-SRC\fop-0.20.5\src\foschema\fop.xsd">

    </xsl:stylesheet>



    When I validated this in XML spy it gives me following error :

    "The file is not valid: The element declaration was not found for root
    element 'xsl:stylesheet'"


    Can anybody see the problem?

    Regards
    Vijay
    Vijay, Oct 31, 2005
    #1
    1. Advertising

  2. In article <>,
    Vijay <> wrote:

    >xmlns:xsl="http://www.w3.org/1999/XSL/Format"


    This should probably be xmlns:xsl="http://www.w3.org/1999/XSL/Transform".

    >xsi:schemaLocation="http://www.w3.org/1999/XSL/Format
    >C:\FOP-SRC\fop-0.20.5\src\foschema\fop.xsd">


    xsi:schemaLocation maps namespace names to URIs, not filenames. Try
    something like file://C:/FOP-SRC/fop-0.20.5/src/foschema/fop.xsd.

    -- Richard
    Richard Tobin, Oct 31, 2005
    #2
    1. Advertising

  3. Vijay

    Vijay Guest

    Richard Tobin wrote:
    > In article <>,
    > Vijay <> wrote:
    >
    > >xmlns:xsl="http://www.w3.org/1999/XSL/Format"

    >
    > This should probably be xmlns:xsl="http://www.w3.org/1999/XSL/Transform".
    >
    > >xsi:schemaLocation="http://www.w3.org/1999/XSL/Format
    > >C:\FOP-SRC\fop-0.20.5\src\foschema\fop.xsd">

    >
    > xsi:schemaLocation maps namespace names to URIs, not filenames. Try
    > something like file://C:/FOP-SRC/fop-0.20.5/src/foschema/fop.xsd.
    >
    > -- Richard


    Thanks Richard, I tired all of above, but XML Spy complains as before
    about <xsl:stylesheet> element. I was just wondering if it is legal to
    have xsd reference in xsl:stylesheet element
    Vijay, Nov 1, 2005
    #3
  4. Vijay wrote:

    > but XML Spy complains as before
    > about <xsl:stylesheet> element. I was just wondering if it is legal to
    > have xsd reference in xsl:stylesheet element


    Well you need a schema then defines the elements in the XSLT namespace
    http://www.w3.org/1999/XSL/Transform and that then manages to allow the
    literal result elements such a stylesheet can have.
    And in your original post you had

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Format"

    where I assume you want

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Nov 1, 2005
    #4
  5. Vijay

    Vijay Guest

    Martin Honnen wrote:
    > Vijay wrote:
    >
    > > but XML Spy complains as before
    > > about <xsl:stylesheet> element. I was just wondering if it is legal to
    > > have xsd reference in xsl:stylesheet element

    >
    > Well you need a schema then defines the elements in the XSLT namespace
    > http://www.w3.org/1999/XSL/Transform and that then manages to allow the
    > literal result elements such a stylesheet can have.
    > And in your original post you had
    >
    > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Format"
    >
    > where I assume you want
    >
    > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    >
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/



    I tried that after Richard pointed out. It still gives the error.

    Vijay
    Vijay, Nov 1, 2005
    #5
  6. Vijay wrote:

    > I tried that after Richard pointed out. It still gives the error.


    Does that schema you use define any element named stylesheet in the
    namespace http://www.w3.org/1999/XSL/Transform?
    It does not help to reference a schema that does not define the elements
    you use.
    You need
    xsi:schemaLocation="http://www.w3.org/1999/XSL/Transform
    URLToSchemaForThatNamespaceHere"

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Nov 1, 2005
    #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. Markus
    Replies:
    1
    Views:
    1,530
    Markus
    Nov 23, 2005
  2. Replies:
    1
    Views:
    855
    Martin Honnen
    Jan 14, 2004
  3. stiank81
    Replies:
    4
    Views:
    15,395
    stiank81
    Jun 26, 2005
  4. Rushi
    Replies:
    1
    Views:
    547
  5. Replies:
    5
    Views:
    1,007
    Brian McCauley
    Nov 29, 2006
Loading...

Share This Page