J
John Larson
Hi All,
I am some information from INSPEC database records in XML to build a
relational database of my own. I am currently trying to extract information
by doing an XSLT transform of the XML files into a tab-separated text file
that I want to import into the database. I have run into the following
problem: in some documents there are missing elements, for instance the
volume and issue number of an article is not there (i.e. it is defined in
the DTD, but the element that contains these values happen not to be
included in some documents). This causes a problem because it messes up my
columns as all the rest of the elements I am extracting move left and thus
are placed in wrong columns.
My question is: is there some way in XSLT output a value like "empty" or
"N/A" when some elements are missing?
I use Xalan to do the transformations, and Altova XML spy / Stylevison to
create the XLSTs. Please find a excerpt from my XLST file below; it is the
"vol", "ino" and "voliss" elements that are sometimes empty.
Thank you for any help!
- John
<xsl:for-each select="bibliog">
<xsl:for-each select="jrefg">
<xsl:for-each select="jrog">
<xsl:for-each select="jt">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="ajt">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="vid">
<xsl:for-each select="vol">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="ino">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="voliss">
<xsl:apply-templates/>
</xsl:for-each>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="pgn">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="norefs">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="ti">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="abs">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
</xsl:for-each>
I am some information from INSPEC database records in XML to build a
relational database of my own. I am currently trying to extract information
by doing an XSLT transform of the XML files into a tab-separated text file
that I want to import into the database. I have run into the following
problem: in some documents there are missing elements, for instance the
volume and issue number of an article is not there (i.e. it is defined in
the DTD, but the element that contains these values happen not to be
included in some documents). This causes a problem because it messes up my
columns as all the rest of the elements I am extracting move left and thus
are placed in wrong columns.
My question is: is there some way in XSLT output a value like "empty" or
"N/A" when some elements are missing?
I use Xalan to do the transformations, and Altova XML spy / Stylevison to
create the XLSTs. Please find a excerpt from my XLST file below; it is the
"vol", "ino" and "voliss" elements that are sometimes empty.
Thank you for any help!
- John
<xsl:for-each select="bibliog">
<xsl:for-each select="jrefg">
<xsl:for-each select="jrog">
<xsl:for-each select="jt">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="ajt">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="vid">
<xsl:for-each select="vol">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="ino">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="voliss">
<xsl:apply-templates/>
</xsl:for-each>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="pgn">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="norefs">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="ti">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="abs">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:text> </xsl:text>
</xsl:for-each>