0

I'm able to print all the elements of my xml file, and eventually want to format items as an asciidoctor table. And I have a ways to go but I can't seem to get xsltproc to include my separator symbol and line breaks in the output. My xsl is as follows (elements are printing; I probably need another for loop in there but thats not my issue... Thanks for any input!)

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
  <xsl:output method="text" encoding="UTF-8" />
  <xsl:param name="separator" select="'|'" />
  <xsl:param name="newline" select="'&#10;'" />
  <xsl:strip-space elements="*" />

  <xsl:template match="/lexique">
    <xsl:for-each select="/item">
      <xsl:value-of select="$separator"/>
      <xsl:value-of select="jula"></xsl:value-of>
      <xsl:value-of select="$separator"/>
      <xsl:for-each select="french/translations">
        <xsl:value-of select="definition"></xsl:value-of>
        <xsl:value-of select="$separator" />
        <xsl:value-of select="speech/type"></xsl:value-of>
        <xsl:value-of select="$separator" />
        <xsl:value-of select="speech/type/hint"></xsl:value-of>
        <xsl:value-of select="$separator" />
        <xsl:value-of select="speech/example/jula"></xsl:value-of>
        <xsl:value-of select="$separator" />
        <xsl:value-of select="speech/example/french"></xsl:value-of>
        <xsl:value-of select="$separator" />
        <xsl:value-of select="$newline" />
      </xsl:for-each>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>
<!---<xsl:text>Jula,French,Speech,Hint,Example</xsl:text>
  <xsl:value-of select="$newline" />
-->

xml: (Included for reference)

<?xml version='1.0' encoding='utf-8'?>
 <lexique xmlns="http://www.coastsystems.net"
         xmlns:xsl="http://www.w3.org/2001/XMLSchema-instance"
         xsl:schemaLocation="http://www.coastsystems.net vocabulaire.xsd">
  <item>
    <jula>báara</jula>
    <french>
      <translations>
        <definition>travail</definition>
        <hint>hint</hint>
        <speech>
          <type>n</type>
          <example>
            <source>i ta baara ka ɲi i ma wa ?</source>
            <target>Est-ce que ton travail te satisfait ?</target>
          </example>
          <example>
            <source>i ni barra</source>
            <target>Bonjour/Bon travail !</target>
          </example>
        </speech>
      </translations>
      <translations>
        <definition>travailler</definition>
        <hint/>
        <speech>
          <type>vi</type>
          <example>
            <source>i be baara kɛ</source>
            <target>Il travaille</target>
          </example>
        </speech>
        <speech>
          <type>vt</type>
          <example>
            <source>i be baara la</source>
            <target>Il est au travail</target>
          </example>
          <example>
            <source>a be nɛgɛ baara</source>
            <target>il travaille le fer</target>
          </example>
        </speech>
      </translations>
    </french>
  </item>
</lexique>
Boyd
  • 351
  • 4
  • 14
  • You are right: the issue is elsewhere. – michael.hor257k Oct 22 '20 at 22:09
  • 1
    The main issue is you're not accounting for the default namespace "`http://www.coastsystems.net`". What you're seeing for output is the text because of the [built-in template rules](https://www.w3.org/TR/xslt-10/#built-in-rule). – Daniel Haley Oct 22 '20 at 22:17

0 Answers0