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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:32:51+00:00 2026-05-23T09:32:51+00:00

I’m very new to XSLT but have some programming experience. I’m finding how XSL

  • 0

I’m very new to XSLT but have some programming experience. I’m finding how XSL works pretty weird sometimes, but enjoying the challenge. At

this stage I just need some advice to point me in the right direction so I can research for myself and the problem I’m describing hasn’t even

occurred yet, but I’m sure it will when we go from ‘testing’ to ‘live’ so I will need to know how to handle it. At the moment I’m hard coding

indexs to get the values and this works fine for nodes I know that won’t change, but some surely will so I need an alternative to my bodgy

hardcoding.

Also, I tried to use global variables for my repetitive ‘"’ and ‘, ‘ code below to make code easier to read but they kept coming up out

of scope (so they were local?). Couldn’t see what I was doing wrong, or where to declare them. Ideally I want to do it at the begining of the

script and be able to call them whenever and wherever I want but this is not urgent.

For example, at the moment I’m using this;

<!-- AHPRA XML CSV Converter Script -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" media-type="text" encoding="UTF-8" indent="no" />
<xsl:strip-space elements="*" />

  <xsl:param name="component"/>

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

    <!-- COMPONENT 4 communications -->
    <!-- contactID, mediumCode, areaCode, communicationDetails -->
    <xsl:when test="$component=4">
      <xsl:for-each select="//person">
        <xsl:if test="string-length(concat(
          communications/communication/mediumCode, 
          communications/communication/areaCode, 
          communications/communication/communicationDetails))!=0">
          <xsl:value-of select="concat(
          '&quot;', contactID, '&quot;', ', ', '&quot;', 
          communications/communication[1]/mediumCode, '&quot;', ', ', '&quot;', 
          communications/communication[1]/areaCode, '&quot;', ', ', '&quot;', 
          communications/communication[1]/communicationDetails, '&quot;', '&#xa;', 
          '&quot;', contactID, '&quot;', ', ', '&quot;', 
          communications/communication[2]/mediumCode, '&quot;', ', ', '&quot;', 
          communications/communication[2]/areaCode, '&quot;', ', ', '&quot;', 
          communications/communication[2]/communicationDetails, '&quot;', '&#xa;', 
          '&quot;', contactID, '&quot;', ', ', '&quot;', 
          communications/communication[3]/mediumCode, '&quot;', ', ', '&quot;', 
          communications/communication[3]/areaCode, '&quot;', ', ', '&quot;', 
          communications/communication[3]/communicationDetails, '&quot;', '&#xa;')" />
        </xsl:if>
      </xsl:for-each>
    </xsl:when>

    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>

On this;

<medicare>  
  ...
  <person>
    <contactID>5290001890</contactID>
    <communications>
      <communication>
        <mediumCode>T</mediumCode>
      <areaCode>02</areaCode>
        <communicationDetails>92881781</communicationDetails>
      </communication>
      <communication>
        <mediumCode>E</mediumCode>
        <communicationDetails>rabina.smiley@ekit.com</communicationDetails>
      </communication>
    <communication>
        <mediumCode>M</mediumCode>
        <communicationDetails>04290012333</communicationDetails>
      </communication>
    </communications>
  </person>
  <person>
    <contactID>4400139361</contactID>
    <communications>
      <communication>
        <mediumCode>T</mediumCode>
      <areaCode>07</areaCode>
        <communicationDetails>49281771</communicationDetails>
      </communication>
      <communication>
        <mediumCode>E</mediumCode>
        <communicationDetails>suzanne.jones2@optus.com</communicationDetails>
      </communication>
    <communication>
        <mediumCode>M</mediumCode>
        <communicationDetails>0404009266</communicationDetails>
      </communication>
    </communications>
  </person>
  ...
</medicare> 

To get this;

contactID,mediumCode,areaCode,communicationDetails
"5290001890", "T", "02", "92881781"
"5290001890", "E", "", "rabina.smiley@ekit.com"
"5290001890", "M", "", "04290012333"
"4400139361", "T", "07", "49281771"
"4400139361", "E", "", "suzanne.jones2@optus.com"
"4400139361", "M", "", "0404009266"

But I’m worried this will not work if my daily xml file changes to this;

<medicare>  
  ...
  <person>
    <contactID>5290001890</contactID>
    <communications>
       <communication>
        <mediumCode>E</mediumCode>
        <communicationDetails>rabina.smiley@ekit.com</communicationDetails>
      </communication>
    <communication>
        <mediumCode>M</mediumCode>
        <communicationDetails>04290012333</communicationDetails>
      </communication>
    </communications>
  </person>
  <person>
    <contactID>4400139361</contactID>
    <communications>
      <communication>
        <mediumCode>T</mediumCode>
      <areaCode>07</areaCode>
        <communicationDetails>49281771</communicationDetails>
      </communication>
      <communication>
        <mediumCode>E</mediumCode>
        <communicationDetails>suzanne.jones2@optus.com</communicationDetails>
      </communication>
    <communication>
        <mediumCode>M</mediumCode>
        <communicationDetails>0404009266</communicationDetails>
    </communications>
  </person>
  ...
</medicare> 

Or this;

<medicare>  
  ...
  <person>
    <contactID>5290001890</contactID>
    <communications>
      <communication>
        <mediumCode>T</mediumCode>
    <areaCode>02</areaCode>
        <communicationDetails>92881781</communicationDetails>
      </communication>
      <communication>
        <mediumCode>E</mediumCode>
        <communicationDetails>rabina.smiley@ekit.com</communicationDetails>
      </communication>
    <communication>
        <mediumCode>M</mediumCode>
        <communicationDetails>04290012333</communicationDetails>
      </communication>
      <communication>
        <mediumCode>X</mediumCode>
    <areaCode>XX</areaCode>
        <communicationDetails>XXXX</communicationDetails>
      </communication>
    </communications>
  </person>
  <person>
    <contactID>4400139361</contactID>
    <communications>
      <communication>
        <mediumCode>T</mediumCode>
      <areaCode>07</areaCode>
        <communicationDetails>49281771</communicationDetails>
      </communication>
      <communication>
        <mediumCode>E</mediumCode>
        <communicationDetails>suzanne.jones2@optus.com</communicationDetails>
      </communication>
    <communication>
        <mediumCode>M</mediumCode>
        <communicationDetails>0404009266</communicationDetails>
      </communication>
    </communications>
  </person>
  ...
</medicare> 
  • 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-23T09:32:52+00:00Added an answer on May 23, 2026 at 9:32 am

    This uses the push style so its only applying the template to the nodes which exsist!
    you will find once you get to grips with xslt its very powerful!

    <!-- AHPRA XML CSV Converter Script -->
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="text" media-type="text" encoding="UTF-8" indent="no" />
    <xsl:strip-space elements="*" />
    
      <xsl:param name="component"/>
    
      <xsl:template match="/">
        <xsl:choose>
    
        <!-- COMPONENT 4 communications -->
        <!-- contactID, mediumCode, areaCode, communicationDetails -->
        <xsl:when test="$component=4">
            <xsl:apply-templates select="//person/communications/communication" />
        </xsl:when>
        </xsl:choose>
      </xsl:template>
    <xsl:template match="person/communications/communication">
                    <xsl:value-of select="concat(
              '&quot;', ../../contactID, '&quot;', ', ', '&quot;', 
              mediumCode, '&quot;', ', ', '&quot;', 
              areaCode, '&quot;', ', ', '&quot;', 
              communicationDetails, '&quot;', '&#xa;')"/>
            </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I have some data like this: 1 2 3 4 5 9 2 6
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.