Your code wasn't working because your source in no-namespace
isn't being selected by XPath expressions trying to match elements the http://xmlapp.fm.net/ns/app/service
namespace. The solution is either declare that namespace as default in your source (adding a xmlns
attribute) or fix the expressions in your XSLT so they match no-namespace.
1) To fix it changing the XSLT remove the myns:
prefixes from your XPath elements.
From the myns:annotation
in the annotationsTable
template:
<xsl:template name="annotationsTable">
...
<fo:table-body>
<xsl:apply-templates select="annotation" />
</fo:table-body>
</fo:table>
</xsl:template>
and from myns:annotation
and myns:text
elements in the myns:annotation
template:
<xsl:template match="annotation">
<fo:table-row>
<fo:table-cell>
<fo:block>
<xsl:value-of select="text" />
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="@createdByName"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="@createdByUserID" />
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="@systemDate" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
Now it should generate the table body contents.
2) If the namespace prefix was there in the first place, it might be that your source originally had a namespace. In this case you leave your XSLT as is, and edit your source, declaring a default namespace:
<annotation xmlns="http://xmlapp.fm.net/ns/app/service"
createdByName="Frank" createdByUserID="X1234" systemDate="2014-04-14">
<text>this is the text of an annotation</text>
</annotation>
Now all elements belong to the "http://xmlapp.fm.net/ns/app/service" namespace, and your XSLT maps that namespace to a prefix (myns
) so you can select the nodes of the source tree in XPath.