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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:01:45+00:00 2026-06-03T05:01:45+00:00

I´m trying to copy an Attribute value from one element in the schema to

  • 0

I´m trying to copy an Attribute value from one element in the schema to the XSLT output.
I tried copy-of, and visited a lot of examples with schema-element but it seems only used for matching or copying whole node structures…

Summing up, I would like to take profit of the xslt xsd awareness for doing the equivalent of the Post-Schema-Validation Infosetway of assigning default values to attributes

XML

     <MyProject Val="wrongval">

XSD

     <xs:element name="MyProject">
       <xs:complexType>
         <xs:attribute name="Val" fixed="1234" />
       </xs:complexType>
     </xs:element>

XSLT

    <xsl:template match="/">
       <xsl:element name="MyProject">
          <xsl:attribute name="Val">**???=1234**</xsl:attribute>
       </xsl:element>
    </xsl:template>
  • 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-03T05:01:46+00:00Added an answer on June 3, 2026 at 5:01 am

    You’re nearly there. Given the following (unused) source document:

    <MyProject Val="wrongval"/>
    

    and the following schema:

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    
         <xs:element name="MyProject">
           <xs:complexType>
             <xs:attribute name="Val" fixed="1234" />
           </xs:complexType>
         </xs:element>
    
    </xs:schema> 
    

    and the following stylesheet:

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
        <xsl:import-schema schema-location="test.xsd"/>
    
        <xsl:template match="/">
           <xsl:element name="MyProject" validation="strict"/>
        </xsl:template>
    
    </xsl:stylesheet>
    

    the transformation output is:

    <?xml version="1.0" encoding="UTF-8"?><MyProject Val="1234"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to copy all of my output files from the solution target
I'm trying copy a single file from the Plugin directory inside of my Wordpress
I'm trying to copy both an image from a file and text from a
I am trying to copy a file from my remote server to my local.
I am trying to copy data from my MYSQL table to SQL Server using
Trying to achieve the goal of printing selected page's element ONE-TO-ONE - the exact
I am trying to add an attribute to a node selected from the source
I am trying to create a new XML file from an exisiting one using
I'm trying to piece together info from these two answers, but neither seems to
I am currently trying to copy an array I have to a new view

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.