Jump to content

xref conversion problem


dklim

Recommended Posts

I'm converting a note that has two inline empty element xrefs in it. I can get the xref tag to convert inline within the para tags but the attribute values of the refint (converted xref) are outputed like they are accumulating not the lone value when the xref occurrs. Please help.XML PIECE<?xml version="1.0" encoding="UTF-8"?><doc><note><paratext>Test cable is to be manufactured from 3 conductor cables with standard AC plug on one end and a P/N MS3106-F24-7S connector, see figure <xref xrefid="figure1" xidtype="figure"/> and table <xref xrefid="table2" xidtype="table"/></paratext></note></doc>XSLT PIECE<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">'>http://www.w3.org/2005/xpath-functions"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/doc"> <doc><xsl:apply-templates/></doc> </xsl:template> <xsl:template match="note"> <note><xsl:apply-templates/></note> </xsl:template> <xsl:template match="paratext"> <para><xsl:apply-templates/></para> </xsl:template> <xsl:template match="xref"> <xsl:apply-templates/> <xsl:variable name="refidval" select="//xref/@xrefid"/> <xsl:variable name="reftypeval" select="//xref/@xidtype"/> <refint refid="{$refidval}" reftype="{$reftypeval}"/> </xsl:template></xsl:stylesheet>BAD OUTPUT<?xml version="1.0" encoding="UTF-8"?><doc xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <note> <para>Test cable is to be manufactured from 3 conductor cables with standard AC plug on one end and a P/N MS3106-F24-7S connector, see figure <refint refid="figure1 table2" reftype="figure table"/> :) and table <refint refid="figure1 table2" reftype="figure table"/> :) </para> </note></doc>NOTE the accumulative attribute values in the refid!Thanks

Link to comment
Share on other sites

I'm guessing an xref must be converted to equivalent refint element, right?Well, if so, the template

<xsl:template match="xref"><xsl:apply-templates/> <xsl:variable name="refidval" select="//xref/@xrefid"/> <xsl:variable name="reftypeval" select="//xref/@xidtype"/><refint refid="{$refidval}" reftype="{$reftypeval}"/></xsl:template>

doesn't need to select anything above itself (by using the "//"). Try simply

<xsl:template match="xref"><xsl:apply-templates/> <refint refid="{@xrefid}" reftype="{@xidtype}"/></xsl:template>

Scince you've got a match attribute, everything inside is selected relatively from that element, eliminating the need for "//".

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...