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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:43:01+00:00 2026-05-27T12:43:01+00:00

I am new to XSLT I am trying to transform a name value pair

  • 0

I am new to XSLT I am trying to transform a name value pair to its corresponding XML. This feature is primarily used in case of special extensions to a standard. The file I want to transform is the following.

<ODEventNotificationExtraField>
<callCode>1</callCode>
<callbackType>All </callbackType>
<callbackEmail>me@mine.org </callbackEmail>
</ODEventNotificationExtraField>

to the following:

<?xml version="1.0" encoding="UTF-8"?>
<extensionList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="ExtensionItems.xsd">
<extensionsItem>
<extName> callCode</extName>
<extValue>1</extValue>
<extType>integer</extType>
</extensionsItem>
<extensionsItem>
<extName>callbackType</extName>
<extValue>All</extValue>
<extType>string</extType>
</extensionsItem>
<extensionsItem>
<extName>callbackEmail</extName>
<extValue>me@mine.org</extValue>
<extType>string</extType>
</extensionsItem>
</extensionsList>

Based On the Field Name for example CallCode I will know it is of type integer( it needs to be hardcoded in xslt)
the xmlschema for the incoming data is defined as

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:simpleType name="CallbackType">
<xs:restriction base="xs:string">
<xs:enumeration value="Restoration"/>
<xs:enumeration value="Estimated"/>
<xs:enumeration value="All"/>
<xs:enumeration value="None"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="ODEventNotificationExtraField">
<xs:complexType>
<xs:sequence>
<xs:element name="callCode" type="xs:integer" minOccurs="0"/>
<xs:element name="callbackType" type="CallbackType" minOccurs="0"/>
<xs:element name="callbackEmail" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
  • 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-27T12:43:02+00:00Added an answer on May 27, 2026 at 12:43 pm

    The following stylesheet produces the intended result:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                    xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
        <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
        <!-- element list -->
        <xs:element name="callCode" type="xs:integer"/>
        <xs:element name="callbackType" type="xs:string"/>
        <xs:element name="callbackEmail" type="xs:string"/>
        <xsl:template match="/">
            <extensionItems xs:noNamespaceSchemaLocation="ExtensionItems.xsd">
                <extensionsList>
                    <xsl:apply-templates select="/ODEventNotificationExtraField/*"/>
                </extensionsList>
            </extensionItems>
        </xsl:template>
        <xsl:template match="*">
            <extensionsItem>
                <extName><xsl:value-of select="local-name()"/></extName>
                <extValue><xsl:value-of select="."/></extValue>
                <extType>
                    <xsl:value-of 
                        select="substring-after(document('')/*/xs:element[
                            @name=current()/local-name()]/@type, ':')"/>
                    </extType>
            </extensionsItem>
        </xsl:template>
    </xsl:stylesheet>
    

    Notice the hard-coding of element types and use of document to retrieve them.

    Output:

    <extensionItems xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
                    xs:noNamespaceSchemaLocation="ExtensionItems.xsd">
       <extensionsList>
          <extensionsItem>
             <extName>callCode</extName>
             <extValue>1</extValue>
             <extType>integer</extType>
          </extensionsItem>
          <extensionsItem>
             <extName>callbackType</extName>
             <extValue>All</extValue>
             <extType>string</extType>
          </extensionsItem>
          <extensionsItem>
             <extName>callbackEmail</extName>
             <extValue>me@mine.org</extValue>
             <extType>string</extType>
          </extensionsItem>
       </extensionsList>
    </extensionItems>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to XSLT I am trying to transform a name value pair
I'm new to XML/XSLT and am having an issue trying to change an image
Hi I'm new to XSLT and I'm trying to display the value of a
I'm trying to write an XSLT that will transform an XML document that I
I’ve been trying to transform some simple XML into another simple XML using XSLT.
I am new to XML and its related languages. I am trying to do
i am pretty new to XSLT / XML and HTML. I have a XML
I've written a simple XML Document that I am trying to transform with an
I'm trying to post-process the documentation XML file as a post-build XSLT transformation (using
am trying to flatten an XML element based on a child element name using

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.