This generates XML for posting to a job board. I did not come up with the system and don't know very much about XSLT. But for some reason, the HTML tags like <h3>
are getting stripped out of the description text which breaks the formatting and makes the post on the job board look a mess.
I can't for the life of me figure out how to prevent this from happening:
the problem is specifically this bit:
<member>
<name>description</name>
<value>
<xsl:value-of select="job_intro" />
<xsl:value-of select="location_description" />
<xsl:value-of select="job_description" />
<xsl:value-of select="brand_desc" />
</value>
</member>
The xsl:value-of select="location_description"
for example is stripping out the html formatting and I want to keep it in.
Here is the full thing:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:param name="transaction"/>
<xsl:param name="adtype"/>
<xsl:param name="testmode"/>
<xsl:param name="username"/>
<xsl:param name="password"/>
<xsl:variable name="apos" select='"'"'/>
<xsl:output method = "xml" omit-xml-declaration="no" encoding="iso-8859-1" indent="yes"/>
<xsl:template match="pb_ad">
<xsl:if test="$transaction!='DELETE'">
<methodCall>
<methodName>submitJob</methodName>
<params>
<param><value><struct>
<member><name>source</name><value><i4>76</i4></value></member>
<member>
<name>username</name>
<value>
<string>
<xsl:choose>
</xsl:choose>
</string>
</value>
</member>
<member>
<name>password</name>
<value>
<string>
<xsl:choose>
</xsl:choose>
</string>
</value>
</member>
<member><name>reference</name><value><i4><xsl:value-of select="@id" /></i4></value></member>
<member><name>title</name><value><string><xsl:value-of select="headline"/></string></value></member>
<member><name>industry</name><value><i4>27</i4></value></member>
<member><name>type</name><value><string>
<xsl:choose>
<xsl:when test="employment_term_id=2">contract</xsl:when>
<xsl:when test="employment_term_id=5">temporary</xsl:when>
<xsl:when test="employment_term_id=6">part_time</xsl:when>
<xsl:otherwise>permanent</xsl:otherwise>
</xsl:choose>
</string></value></member>
<member><name>salary_min</name><value><i4><xsl:value-of select="salaryfrom"/></i4></value></member>
<member><name>salary_max</name><value><i4><xsl:value-of select="salaryto"/></i4></value></member>
<member><name>salary_period</name><value><i4>
<xsl:choose>
<xsl:when test="pay_period_id=2">405</xsl:when>
<xsl:when test="pay_period_id=3">406</xsl:when>
<xsl:when test="pay_period_id=4">407</xsl:when>
<xsl:when test="pay_period_id=5">404</xsl:when>
<xsl:otherwise>403</xsl:otherwise>
</xsl:choose>
</i4></value></member>
<member><name>salary_info</name><value><string><xsl:value-of select="job_salary"/></string></value></member>
<member><name>region</name><value><i4><xsl:value-of select="locations_mapped/location"/></i4></value></member>
<member><name>display_location</name><value><string><xsl:value-of select="hotel"/></string></value></member>
<member><name>precise_location</name><value><string><xsl:value-of select="postcode"/></string></value></member>
<member><name>description</name><value><xsl:value-of select="job_intro" /><xsl:value-of select="location_description" /><xsl:value-of select="job_description" /><xsl:value-of select="brand_desc" /></value></member>
<xsl:if test="apply_online_url!=''">
<member><name>external_url</name><value><string><xsl:value-of select="apply_online_url"/></string></value></member>
<member><name>contact_name</name><value><string><xsl:value-of select="contact_first_name"/><xsl:text> </xsl:text><xsl:value-of select="contact_last_name"/></string></value></member>
<member><name>contact_telephone</name><value><string></string></value></member>
<member><name>contact_email</name><value><string></string></value></member>
</xsl:if>
<xsl:if test="apply_online_url=''">
<member><name>contact_name</name><value><string><xsl:value-of select="contact_first_name"/><xsl:text> </xsl:text><xsl:value-of select="contact_last_name"/></string></value></member>
<member><name>contact_telephone</name><value><string><xsl:value-of select="contact_work_phone"/></string></value></member>
<member><name>contact_email</name><value><string><xsl:value-of select="email"/></string></value></member>
</xsl:if>
<member><name>direct_apply_url</name><value><string></string></value></member>
<member><name>direct_apply_jobid</name><value><string><xsl:value-of select="@id"/></string></value></member>
<member><name>all_industries</name><value><i4>0</i4></value></member>
</struct></value>
</param>
</params>
</methodCall>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
xsl:value-of
will give you the computed text value of the selected node.
If you want to preserve the markup, then should use xsl:copy-of
, which will perform a deep copy and avoid atomization and "flattening" of the markup into a text() node that is being done with xsl:value-of
.