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 4245220
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:48:42+00:00 2026-05-21T03:48:42+00:00

Say I have an XML file which looks like this: <?xml version=1.0 encoding=UTF-8?> <Project

  • 0

Say I have an XML file which looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<Project xmlns="http://My/Project.xsd">
    <Thing Name="test"/>
</Project>

And my XSLT is:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns="http://My/Project.xsd">
    <xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>

    <xsl:template match="Thing">
        <xsl:value-of select="@Name"/>
    </xsl:template>
</xsl:stylesheet>

The output is [NewLine][Tab][NewLine] which matches the spacing of the XML file.

If I change my XSLT to be: (added a prefix)

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns:N="http://My/Project.xsd">
    <xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>

    <xsl:template match="N:Thing">
        <xsl:value-of select="@Name"/>
    </xsl:template>
</xsl:stylesheet>

The output is [NewLine][Tab]test[NewLine] which again matches the spacing of the XML file but includes the value of the “Name” attribute.

My expected output is simply test. No new lines, no tabs – it should not follow the format of the XML file at all.

I want to write the XML and XSLT without using prefixes. How can I make this output what I’m expecting?

  • 1 1 Answer
  • 1 View
  • 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-21T03:48:43+00:00Added an answer on May 21, 2026 at 3:48 am

    There are two issues here – first is that you don’t want to specify the namespace prefix and second is that you don’t want to have spaces from source document to affect your output. Let’s discuss them separately.

    Using namespace prefix:
    The short answer is no – you can not write XSL template that matches elements within particular namespace without specifying such namespace using prefix. In your first XSLT you could read template definition like “I want to select node named Thing which doesn’t have any namespace” while what you really want to say is “I want to select node named Thing which has namespace http://My/Project.xsd“. This is the way XPath 1.0 specification works (more details in this article).

    Getting rid of spacing:
    Use <xsl:strip-space elements="*"/> instruction at the beginning of stylesheet to specify that you don’t want spaces from all source elements to be preserved in output document. If you want to preserve some of them use <xsl:preserve-spaces elements="myNode"> as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So say I have this XML file: <?xml version=1.0 encoding=utf-8 standalone=yes?> <Root> <Category Name=Tasties>
I'm trying to read in an xml file which looks like this <?xml version=1.0
Let's say that I have something like this in my web.xml file. <filter name=foo>
Say I have the following XML <?xml version=1.0 encoding=utf-8?> <Person> <FirstName>Bjorn</FirstName> <LastName>Ellis-Gowland</LastName> </Person> That
lets say i have an xml file path.xml that goes like this: <paths> <path
I have an xml file. <?xml version=1.0 encoding=UTF-8?> <channel> <item>content with special character é</item>
I have a web server which returns an XML file. Lets say http://www.foo.bar/foo.php?wantXML=1 How
Lets say I have this XML file: <weather> <temp>24.0</temp> <current-condition iconUrl=http://....>Sunny</current-condition> </weather> I'm trying
lets say i have the following XML <?xml version=1.0 encoding=utf-8?> <names> <name first=John last=Doe/>
say, i have such xml file: <?xml version=1.0?> <catalog> <title>My book catalog</title> <link>http://example.com/catalog</link> <book

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.