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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:35:18+00:00 2026-06-12T15:35:18+00:00

Input: <document xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance type=NOIA xsi:noNamespaceSchemaLocation=sample.xsd> <id>X17A</id> <companyName>Foo Bars</companyName> <p>Lorem ipsum dolor sit amet, consectetur

  • 0

Input:

<document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" type="NOIA" xsi:noNamespaceSchemaLocation="sample.xsd">
<id>X17A</id>
<companyName>Foo Bars</companyName>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis tincidunt turpis id metus porttitor convallis. Duis ullamcorper magna a est suscipit eget blandit magna ullamcorper. Vivamus sit amet auctor elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis tincidunt turpis id metus porttitor convallis. Duis ullamcorper magna a est suscipit eget blandit magna ullamcorper. Vivamus sit <url>http://www.google.com/</url> amet auctor elit.</p>
</document>

Desired Output:

<html>
<body>
<h1>Foo Bars Company</h1>
<div><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis tincidunt turpis id metus porttitor convallis. Duis ullamcorper magna a est suscipit eget blandit magna ullamcorper. Vivamus sit amet auctor elit.</p></div>
<div><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis tincidunt turpis id metus porttitor convallis. Duis ullamcorper magna a est suscipit eget blandit magna ullamcorper. Vivamus sit <a href="http://www.google.com/">http://www.google.com/</a> amet auctor elit.</p></div>
</body>
</html>

Here is as far as I got with the sheet:

<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    version="1.0">

<xsl:output method="html" indent="yes" version="4.0"/>

<xsl:template match="/">
<html>
  <body>
    <xsl:apply-templates/>
  </body>
</html>
</xsl:template>

<xsl:template match="id"></xsl:template>

<xsl:template match="companyName">
<h1><xsl:value-of select="."/></h1>
</xsl:template>

<xsl:template match="url">
<a href="#test"><xsl:value-of select="."/></a>
</xsl:template>

<xsl:template match="p">
<div><p><xsl:value-of select="."/></p></div>
</xsl:template>

</xsl:stylesheet>

I can’t figure out how to put the value in the href=””

Also, this doesn’t end up with an href, I’m just getting the text in a p.

  • 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-12T15:35:19+00:00Added an answer on June 12, 2026 at 3:35 pm

    When this XSLT:

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="2.0">
      <xsl:output omit-xml-declaration="no" indent="yes" />
      <xsl:strip-space elements="*" />
    
      <xsl:template match="node()|@*">
        <xsl:copy>
          <xsl:apply-templates select="node()|@*" />
        </xsl:copy>
      </xsl:template>
    
      <xsl:template match="url">
        <a href="{.}">
          <xsl:apply-templates />
        </a>
      </xsl:template>
    
      <xsl:template match="/*">
        <html>
          <body>
            <xsl:apply-templates select="*" />
          </body>
        </html>
      </xsl:template>
    
      <xsl:template match="id" />
    
      <xsl:template match="companyName">
        <h1>
          <xsl:value-of select="concat(., ' Company')" />
        </h1>
      </xsl:template>
    
      <xsl:template match="p">
        <div>
          <p>
            <xsl:apply-templates />
          </p>
        </div>
      </xsl:template>
    </xsl:stylesheet>
    

    …is applied to the originally provided XML:

    <?xml version="1.0" encoding="utf-8"?>
    <document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    type="NOIA" xsi:noNamespaceSchemaLocation="sample.xsd">
      <id>X17A</id>
      <companyName>Foo Bars</companyName>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis
      tincidunt turpis id metus porttitor convallis. Duis ullamcorper
      magna a est suscipit eget blandit magna ullamcorper. Vivamus sit
      amet auctor elit.</p>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis
      tincidunt turpis id metus porttitor convallis. Duis ullamcorper
      magna a est suscipit eget blandit magna ullamcorper. Vivamus sit 
      <url>http://www.google.com/</url>amet auctor elit.</p>
    </document>
    

    …the desired result is produced:

    <html>
      <body>
        <h1>Foo Bars Company</h1>
        <div>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
          Duis tincidunt turpis id metus porttitor convallis. Duis
          ullamcorper magna a est suscipit eget blandit magna
          ullamcorper. Vivamus sit amet auctor elit.</p>
        </div>
        <div>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
          Duis tincidunt turpis id metus porttitor convallis. Duis
          ullamcorper magna a est suscipit eget blandit magna
          ullamcorper. Vivamus sit 
          <a href="http://www.google.com/">
          http://www.google.com/</a>amet auctor elit.</p>
        </div>
      </body>
    </html>
    

    Note that this solution will work with either XSLT 1.0 or XSLT 2.0.

    Explanation:

    • The first template is The Identity Transform. It’s purpose is to copy all nodes and attributes as-is from the source document to the result document.

    • The second template matches any <url> element found in the document. Upon finding a <url> element, a new <a> element is created, given an href attribute that matches the original value of the <url> element (via XSLT’s AVT [Attribute Value Template] functionality), and given a value that matches that original <url> value.

    Note that if elements other than <url> need to be replaced in this same manner, you can simply alter the match attribute of the second template as necessary. For example:

    <xsl:template match="url|some-other-element|yetAnotherElement">
    
    • The third template matches any <id> element and, in place of that element, outputs nothing (which effectively deletes that element).

    • The fourth template matches any <companyName> element. In its place, a new <h1> element is created and given a value that is a concatenation of <companyName>‘s value and ” Company”.

    • The fifth template matches any <p> element and wraps it in a <div> element.

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

Sidebar

Related Questions

<wsdl:definitions xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/ xmlns:soap=http://schemas.xmlsoap.org/wsdl/soap/ xmlns:tns=http://ttdev.com/ss xmlns:xsd=http://www.w3.org/2001/XMLSchema xmlns:sp=http://schemas.xmlsoap.org/ws/2005/07/securitypolicy xmlns:wsp=http://schemas.xmlsoap.org/ws/2004/09/policy xmlns:wsu=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-utility-1.0.xsd name=SecureService targetNamespace=http://ttdev.com/ss> <wsp:Policy wsu:Id=p1> <sp:SignedParts> <sp:Body
I have the following XSD file: <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://www.wvf.com/schemas' xmlns='http://www.wvf.com/schemas' xmlns:acmewvf='http://www.wvf.com/schemas'> <xs:element name='loft'> </xs:element>
I have this XML <Results SchemaVersion=1.0 SchemaType=Results GroupId=-12345 xmlns=http://xyz xmlns:xs=http://www.w3.org/2001/XMLSchema-instance> <Attempt> <Time>2007-03-30T15:58:15</Time> <Message>This is
here is my code <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> <html xmlns=http://www.w3.org/1999/xhtml xmlns:fb=http://www.facebook.com/2008/fbml>
http://jsfiddle.net/wDddR/3/ var input = document.createElement(input); input.onclick = function (ev) { console.log(ev.timeStamp === 0 ?
I have this: $(document).ready(function() { $(input[type=button]).click(function () { $(#test).html(W3Schools); alert(Would submit: + $(this).siblings(input[type=text]).val()); $.ajax({
In Scala REPL: val input = <outerTag xmlns=http://xyz> <innerTag> </innerTag> </outerTag> input\\@innerTag => <innerTag
@Oded: Sorry to have been poor in my exposition... My input document has a
i have the following function function change() { var input = document.getElementById('pas'); var input2
I'm trying to set the focus on a text input element using document.getElementById( 'id'

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.