targetNamespace and XSL

Discussion in 'XML' started by CB, Jun 27, 2003.

  1. CB

    CB Guest

    I'm just picking up XSL, and am having problems with namespaces. None
    of the posts I've read through/tried seem to work so I must be missing
    something basic. Please help.

    I started with a simple example, and created an XSD, XML and XSL that
    work. They are;

    ---XSD--
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="source">
    ...

    --XML--
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="Page3.xsl"?>
    <source>
    ...

    --XSL--
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:template match="source">
    <xsl:apply-templates select="bold"/>
    <xsl:apply-templates select="red"/>
    <xsl:apply-templates select="italic"/>
    </xsl:template>
    ...


    As I said, this all works, and I get my expected outputs. Now,
    I want to add a targetNamespace to the XSD. So, I've changed my
    three files as follows;


    ---XSD--
    <xs:schema targetNamespace="Page3"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:p3="Page3"
    elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="source">
    ...

    --XML--
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="Page3tns.xsl"?>
    <source xmlns="Page3"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="Page3 Page3tns.xsd">
    ...

    --XSL--
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:page3="x-schema:page3tns.xsd">
    <xsl:template match="Page3:source">
    <xsl:apply-templates select="Page3:bold"/>
    <xsl:apply-templates select="Page3:red"/>
    <xsl:apply-templates select="Page3:italic"/>
    </xsl:template>
    ...

    This won't work. I've tried several variations on the namespace
    for p3 and Page3, and I've gotten various error messages and
    incorrect output.

    So, what is the correct line for declaring the Page3 namespace in
    the XSL?
    CB, Jun 27, 2003
    #1
    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. kevin bailey

    targetnamespace - what is it?!?!

    kevin bailey, Jun 24, 2003, in forum: XML
    Replies:
    1
    Views:
    17,418
    kevin bailey
    Jun 25, 2003
  2. C. M. Sperberg-McQueen

    Re: transforming to an XML Schema - targetNamespace

    C. M. Sperberg-McQueen, Jul 29, 2003, in forum: XML
    Replies:
    0
    Views:
    526
    C. M. Sperberg-McQueen
    Jul 29, 2003
  3. Charles Fineman

    targetNamespace/import conflict

    Charles Fineman, Jan 21, 2004, in forum: XML
    Replies:
    2
    Views:
    4,201
    Charles Fineman
    Feb 9, 2004
  4. Gianni Rubagotti
    Replies:
    1
    Views:
    537
    Patrick TJ McPhee
    Feb 5, 2004
  5. Markus Meckler
    Replies:
    3
    Views:
    694
    Priya Lakshminarayanan [MSFT]
    Jun 29, 2004
Loading...

Share This Page