xml - TEI and XSLT: No content in output file -
i have xml document structured in tei "standard", maybe of know it. made xslt transform xml structure.
but came problem. transformation process doesn't reach specific node in xml structure.
the original document looks following:
<tei xmlns="http://www.tei-c.org/ns/1.0" xmlns:tgl="http://******/namespaces /metadata/language/2010" xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:tns="http://*****/namespaces/metadata/core/2010" xmlns:tgr="http://*****/namespaces/metadata/agent/2010" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:tgs="http://*****/namespaces/metadata/script/2010" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xml:id="tg397" n="/literatur/m/birlinger, anton/märchen und sagen/sagen, märchen, volksaberglauben/3./299. von den sternen/2. [die sterne halten viele für die köpfe silberner nägel]"> <teiheader xmlns:xi="http://www.w3.org/2001/xinclude" xmlns:a="http://www.*****/namespace/digibib/authors" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <filedesc> <titlestmt> <title> hshshhshs </title> </titlestmt> <publicationstmt> .... with xslt try reach nodes. because doesn't try simple example, can't reach content of . xslt:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0"> <xsl:output method="xml" indent="yes" encoding="utf-8"/> <!--<xsl:template match="/tei">--> <xsl:template match="/"> <add><doc> <field name="title"> <xsl:value-of select="tei/teiheader/filedesc/titlestmt/title"/> </field>- </doc></add> </xsl:template> </xsl:stylesheet> and result:
<?xml version="1.0" encoding="utf-8"?> <add> <doc> <field name="title"/>- </doc> </add> i hope of can me.
this because tei document starts off line
<tei xmlns="http://www.tei-c.org/ns/1.0" this means elements within document, unless otherwise specfied namespace prefix, in namespace ""http://www.tei-c.org/ns/1.0"
however, in xslt document trying select elements no namespace, , doesn't match ones in tei have namespace.
the solution first declare relevant namespace in xslt document, using prefix like:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:tei="http://www.tei-c.org/ns/1.0" version="1.0"> then can write xlst statement so
<xsl:value-of select="tei:tei/tei:teiheader/tei:filedesc/tei:titlestmt/tei:title"/>
Comments
Post a Comment