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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:30:31+00:00 2026-06-10T20:30:31+00:00

I found many solution for this problem on internet (and in this forum too),

  • 0

I found many solution for this problem on internet (and in this forum too), but still I can resolve my problem.
I have this code:

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tei="http://www.tei-c.org/ns/1.0"
    exclude-result-prefixes="#default">
    <xsl:output omit-xml-declaration="yes" standalone="no" method="xml" indent="no" />

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>

    </xsl:template>

    <xsl:template match="tei:body">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
        <back>
            <div>
                <xsl:for-each select="//tei:rs[@type='luogo']">
                    <p><xsl:value-of select="."/></p>
                </xsl:for-each>
            </div></back>
    </xsl:template>
</xsl:stylesheet>

The output is correct except for the back section, that repeats the xmlns and xmlns:tei attributes:

<back xmlns="" xmlns:tei="http://www.tei-c.org/ns/1.0"><div>....</div></back>

they are already here (so I don’t need the “back” ones):

<TEI xmlns="http://www.tei-c.org/ns/1.0">

I tried codes like this:

<xsl:template match="@*|node()[not(self::*)]">
        <xsl:copy/>
    </xsl:template>

    <xsl:template match="*">
        <xsl:element name="{local-name()}">
            <xsl:apply-templates select="node()|@*"/>
        </xsl:element>
    </xsl:template>

Or this:

<xsl:template match="*">
        <xsl:element name="{local-name()}">
            <xsl:apply-templates select="@*|*"/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="tei:back">
        <xsl:attribute name="{local-name()}">
            <xsl:value-of select="."/>
        </xsl:attribute>
    </xsl:template>

I even changed it to make it fit in my code, changing the match or the value of select with “tei:back”, it doesn’t worked.
What I have to do in order to make the tei namespace appear only in the section?
Thank you in advice for your help!


Edit:
Thank you for the answers.
My xml code is like this:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="file:/C:/Users/User/Desktop/prova2.xsl"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
    <teiHeader><fileDesc>
        <titleStmt>
            <title>AA</title>
        </titleStmt>
        <publicationStmt><p><!-- supply publication information --></p></publicationStmt>
        <sourceDesc>
            <bibl>AA</bibl>
        </sourceDesc>
    </fileDesc><profileDesc>
        <langUsage>
            <language ident="ita">AA</language>
            <language ident="lat">AA</language>
        </langUsage>
    </profileDesc></teiHeader>
    <text>
        <body>
            <div type="book" n="3" xml:id="L3">
                <head>AA
                </head>
                <div type="cap" n="1" xml:id="L3-01">
                    <head>AA</head>
                    <p>AA
                        <pb n="200"/>AA      
                    </p>
                </div>
            </div>
        </body>
    </text>
</TEI>

The complete output is like this:

<?xml-stylesheet type="text/xsl" href="file:/C:/Users/User/Desktop/prova2.xsl"?><TEI xmlns="http://www.tei-c.org/ns/1.0">
    <teiHeader><fileDesc>
        <titleStmt>
            <title>AA</title>
        </titleStmt>
        <publicationStmt><p><!-- supply publication information --></p></publicationStmt>
        <sourceDesc>
            <bibl>AA</bibl>
        </sourceDesc>
    </fileDesc><profileDesc>
        <langUsage>
            <language ident="ita">AA</language>
            <language ident="lat">AA</language>
        </langUsage>
    </profileDesc></teiHeader>
    <text>
        <body>
            <div type="book" n="3" xml:id="L3">
                <head>AA
                </head>
                <div type="cap" n="1" xml:id="L3-01">
                    <head>AA</head>
                    <p>AA
                        <pb n="200"/>AA      
                    </p>
                </div>
            </div>
        </body><back xmlns="" xmlns:tei="http://www.tei-c.org/ns/1.0"><div/></back>
    </text>
</TEI>
  • 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-06-10T20:30:33+00:00Added an answer on June 10, 2026 at 8:30 pm

    The issue occurs because in your input XML document, all the elements have been specified to be within the namespace “http://www.tei-c.org/ns/1.0”. However, in your XSLT, you are creating new elements (in the tei:body template) but you are not specifying the namespace of the new elements. This means the new elements, such as back created without a namespace, and so the output XML contains the extra namespace tags to indicate this.

    One way to resolve this is to specify the namespace when creating the element. Instead of doing this….

    <back>....</back>
    

    Do this….

    <xsl:element name="back" namespace="http://www.tei-c.org/ns/1.0">....</xsl:element>
    

    Here is the full XSLT

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tei="http://www.tei-c.org/ns/1.0" exclude-result-prefixes="#default">
       <xsl:output omit-xml-declaration="yes" standalone="no" method="xml" indent="no"/>
    
       <xsl:template match="@*|node()">
          <xsl:copy>
             <xsl:apply-templates select="@*|node()"/>
          </xsl:copy>
       </xsl:template>
    
       <xsl:template match="tei:body">
          <xsl:copy>
             <xsl:apply-templates select="@*|node()"/>
          </xsl:copy>
          <xsl:element name="back" namespace="http://www.tei-c.org/ns/1.0">
             <xsl:element name="div" namespace="http://www.tei-c.org/ns/1.0">
                <xsl:for-each select="//tei:rs[@type='luogo']">
                   <xsl:element name="p" namespace="http://www.tei-c.org/ns/1.0">
                      <xsl:value-of select="."/>
                   </xsl:element>
                </xsl:for-each>
             </xsl:element>
          </xsl:element>
       </xsl:template>
    </xsl:stylesheet>
    

    When applied to your sample XML, the following is output

    <TEI xmlns="http://www.tei-c.org/ns/1.0">
       <teiHeader>
          <fileDesc>
             <titleStmt>
                <title>AA</title>
             </titleStmt>
             <publicationStmt>
                <p><!-- supply publication information -->
                </p>
             </publicationStmt>
             <sourceDesc>
                <bibl>AA</bibl>
             </sourceDesc>
          </fileDesc>
          <profileDesc>
             <langUsage>
                <language ident="ita">AA</language>
                <language ident="lat">AA</language>
             </langUsage>
          </profileDesc>
       </teiHeader>
       <text>
          <body>
             <div type="book" n="3" xml:id="L3">
                <head>AA </head>
                <div type="cap" n="1" xml:id="L3-01">
                   <head>AA</head>
                   <p>AA 
                      <pb n="200"/>AA 
                   </p>
                </div>
             </div>
          </body>
          <back>
             <div/>
          </back>
       </text>
    </TEI>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've run accross this problem many times and still haven't found the solution or
This is a particular problem that I have come across many times, but I
Many people had this problem already, but there was no fitting solution in other
I have found many great answers to this from a year ago (when it
I tried googling for this issue and found many people with the same problem
I have been looking for a solution and I found many different opinions to
My answer: After getting annoyed, I have found a solution. The problem was indeed
This problem was asked many times, but none of solutions doesnt help me. I
I have searched this site for an answer and found many responses to unsigned/signed
I have a solution in C:\full path here\VS2010\blender.sln This solution contains many projects(around 100).

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.