Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3627870
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:56:36+00:00 2026-05-18T23:56:36+00:00

I am fairly new to XSL and need help with a transformation issue. I

  • 0

I am fairly new to XSL and need help with a transformation issue. I have an XML file that is described by an XSD. I use an XSL file to transform the XML into HTML. I want to reference the XSD in the XML file, but when I do the XML doesn’t get transformed.

Example XML:

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

<root>
<!--
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://localhost" xsi:schemaLocation="http://localhost example.xsd">
-->
  <element>Element 1</element>
  <element>Element 2</element>
  <element>Element 3</element>
</root>

Example XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <ul>
      <xsl:for-each select="root/element">
        <li><xsl:value-of select="."/></li>
      </xsl:for-each>
    </ul>
  </xsl:template>
</xsl:stylesheet>

Example XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema 
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://localhost"
  xmlns="http://localhost"
  elementFormDefault="qualified">
  <xs:element name="root">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="element" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

In the XML, if I use the commented out root tag, Firefox and Chrome do not transform the xml. If I just use the plain <root> tag, however, the transformation happens fine.

Can anyone explain why the XSL transformation doesn’t happen if I reference the XSD in my XML? Any help is appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T23:56:37+00:00Added an answer on May 18, 2026 at 11:56 pm
    <!-- <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://localhost" xsi:schemaLocation="http://localhost example.xsd"> -->
    

    This has nothing to do with using an XML Schema. The problem is that you specify a default namespace.

    Using XPath expressions for node names in a default namespace is the biggest XPath FAQ.

    Please, search the xpath and xslt tags for “default namespace” and you’ll find many good answers.

    The solution for XSLT is to declare a namespace with some prefix (say “x”) and namespace-uri that is the same as the namespace-uri of the default namespace in the XML document. Then in any XPath expression use x:name instead of name.

    Thus your XSLT code becomes:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:x="http://localhost" exclude-result-prefixes="x" >
    
        <xsl:template match="/">
            <ul>
                <xsl:for-each select="x:root/x:element">
                    <li>
                        <xsl:value-of select="."/>
                    </li>
                </xsl:for-each>
            </ul>
        </xsl:template>
    </xsl:stylesheet>
    

    and when applied on the provided XML document with uncommented <root> element:

    <root xmlns="http://localhost"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://localhost example.xsd"> 
        <element>Element 1</element>
        <element>Element 2</element>
        <element>Element 3</element>
    </root>
    

    the wanted, correct result is produced:

    <ul>
        <li>Element 1</li>
        <li>Element 2</li>
        <li>Element 3</li>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Fairly new to database schema (plan to use SQLite). Having said that, I'm thinking
I fairly new to regular expressions and need some help. I need to filter
I'm fairly new to XML and XSL Stylesheets, and I've been tasked with creating
Im completely new to XML/XSL/XSLT, and while i have been digging msdn, 3schools.com and
Fairly new to wpf, using the galasoft mvvm templates. I have two relaycommands that
Still fairly new to android, wondered if anyone can help... I have an App
I fairly new to JQuery and perhaps trying to achieve something that might be
I am new to fairly new to AS3 and I have found myself needing
I'm fairly new to ruby and I've got a hash that looks like so:
I am fairly new to php and mysql but I have created a small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.