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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:44:18+00:00 2026-06-02T18:44:18+00:00

(1) Why does Option1 (Template) produce whitespace (mainly btw rec1 & 5) whereas Option2

  • 0

(1) Why does Option1 (Template) produce whitespace (mainly btw rec1 & 5) whereas Option2 (ForEach) doesn’t?
(2) If possible, how do I code Option1 to remove the resulting whitespace?
Assumptions: use of XSLT v1., XMLPad/Stylus for testing, MSXML4.
Working on processing larger, more complex XML input files (mix of elements/attributes) with multiple ‘type’ selection criteria to create multiple TSV output files. A number of references seem to indicate using Templates as the preferable method. Using match currently pushes too much whitespace to the message queue.

XML:

<main>
    <event>
        <event_type>Bike</event_type>
        <date>2012-02-05</date>
    </event>
    <event>
        <event_type>Run</event_type>
        <date>2012-02-06</date>
    </event>
    <event>
        <event_type>Swim</event_type>
        <date>2012-02-07</date>
    </event>
    <event>
        <event_type>Run</event_type>
        <date>2012-02-08</date>
    </event>
    <event>
        <event_type>Bike</event_type>
        <date>2012-02-09</date>
    </event>
</main>

XSL:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="text"/>
  <xsl:variable name="tab" select="'&#09;'" />

<xsl:template match="@*|text()"/>

<xsl:template match="/">
<xsl:text/>event<xsl:value-of select="$tab"/>
<xsl:text/>date<xsl:value-of select="$tab"/>
<xsl:apply-templates/>
</xsl:template>

<!-- OPTION1 -->
<xsl:template match="event[event_type='Bike']"><xsl:text>
</xsl:text>
<xsl:value-of select="event_type"/><xsl:value-of select="$tab"/>
<xsl:value-of select="date"/>
</xsl:template>

<!-- OPTION2 -->
<!--<xsl:template match="@*|node()">
<xsl:for-each select="event[event_type='Bike']"><xsl:text>
</xsl:text>
<xsl:value-of select="event_type"/><xsl:value-of select="$tab"/>
<xsl:value-of select="date"/>
</xsl:for-each>
</xsl:template>-->

</xsl:stylesheet>

Output – Opt1 Template (can’t post pics yet, … are whitespace)

event…date……
Bike….2012-02-05…………
Bike….2012-02-09.

Output – Opt2 ForEach

event…date…..
Bike….2012-02-05
Bike….2012-02-09

  • 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-02T18:44:19+00:00Added an answer on June 2, 2026 at 6:44 pm

    I’ve tried a different editor (Architag XRay Xml Editor, which uses MSXML) and to make it work I had to use CR/LF characters. I believe Dimitre’s answer is right.
    This is my modification:

    <!-- OPTION1 -->
    <xsl:template match="event[event_type='Bike']">
    <xsl:text>&#13;&#10;</xsl:text>
    <xsl:value-of select="event_type"/><xsl:value-of select="$tab"/>
    <xsl:value-of select="date"/>
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the last line of the following code, it has &2, if($page['special']&2). What does
We have some code which produces an RTF document from a RTF template. It
Why does this fail to compile with GCC 4.4? template<typename T> class A {
I'm having a weird problem, I have the following code in my page.php template
When reading apple generated template code as well as in documentation, I see _
I have a line of code below which successfully does a trigger when a
In Rails 2 generators, it's possible to pass data to the template in the
When I enter an abbreviation of a code template and press the expand key
Does anyone know what the -FC option does in g++? I have it in
TTreeNode does not have a Visible property, so the obvious option does not exist.

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.