Subject: Re: [xsl] no attributes outputed when chaining transformations From: Geert Josten <Geert.Josten@xxxxxxxxxxx> Date: Thu, 16 Dec 2004 21:11:53 +0100 |
Michael Kay wrote:
The problem could easily be some slip-up in the template matching rules,Here are my samples, do you see anything that might cause this slip-up?
e.g. a phase-1 template rule being invoked when you intended a phase-2 rule
to fire.
public class MyXMLFilters
{
public static void main(String[] args)
throws TransformerException, TransformerConfigurationException,
SAXException, IOException {
TransformerFactory tFactory = TransformerFactory.newInstance();
if (tFactory.getFeature(SAXSource.FEATURE) && tFactory.getFeature(SAXResult.FEATURE))
{
SAXTransformerFactory saxTFactory = ((SAXTransformerFactory) tFactory);
XMLFilter xmlFilter1 = saxTFactory.newXMLFilter(new StreamSource("0_map_1.xslt"));
XMLFilter xmlFilter2 = saxTFactory.newXMLFilter(new StreamSource("1_map_2.xslt"));
XMLReader reader = XMLReaderFactory.createXMLReader();
xmlFilter1.setParent(reader);
xmlFilter2.setParent(xmlFilter1);
Serializer serializer = SerializerFactory.getSerializer
(OutputPropertiesFactory.getDefaultMethodProperties("xml")); serializer.setOutputStream(System.out);
xmlFilter2.setContentHandler(serializer.asContentHandler());
xmlFilter2.parse(new InputSource("SouthPole.xml"));
}
}
}
****SouthPole.xml*****
<?xml version="1.0" encoding="UTF-8"?>
<testPlan baseDir="${TEST_BASE_DIR}"
fedFile="${IBUILD_HOME}/FOM/${FED_FILE}" federationName="SIAP"
hlaControlDir="${HLA_CONTROL}" ridFile="${RID_FILE}"
rtiBuildType="${RTI_BUILD_TYPE}" rtiExecArgs="${RTI_ARGS}"
rtiHome="${RTI_HOME}" testPlanName="CRSAcceptanceSouthPole"
xmlns="http://www.virtc.com" xmlns:x0="http://www.w3.org/2001/XMLSchema">
</testPlan>
*****Stylesheet 0_map_1.xslt***********
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n12="http://www.virtc.com" xmlns:att="http://www.virtc.com/att" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.virtc.com/jdep/att" exclude-result-prefixes="xs n12 att">
<xsl:output method="xml" encoding="UTF-8"/>
<!--xsl:param name="tpVersion" select="'1'"/-->
<xsl:template match="/n12:testPlan">
<testPlan>
<xsl:attribute name="xsi:schemaLocation">http://www.virtc.com/jdep/att D:/jdep/ATTCON~1/ATT_1_0_8/TestPlan.xsd</xsl:attribute>
<xsl:for-each select="@testPlanName">
<xsl:attribute name="testPlanName">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:for-each select="@baseDir">
<xsl:attribute name="baseDir">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
</testPlan>
</xsl:template>
</xsl:stylesheet>
*****Stylesheet 1_map_2.xslt***********
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n12="http://www.virtc.com/jdep/att" xmlns="http://www.virtc.com/jdep/att" exclude-result-prefixes="xs n12 ">
<xsl:output method="xml" encoding="UTF-8"/>
<!--xsl:param name="tpVersion" select="'2'"/-->
<xsl:template match="/n12:testPlan">
<testPlan>
<xsl:attribute name="xsi:schemaLocation">http://www.virtc.com/jdep/att C:/cvsroot/iBuild/jdep/ATT/dist/TestPlan.xsd</xsl:attribute>
<xsl:for-each select="@testPlanName">
<xsl:attribute name="testPlanName">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:for-each select="@baseDir">
<xsl:attribute name="baseDir">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:for-each select="@federationName">
<xsl:attribute name="federationName">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
</testPlan>
</xsl:template>
</xsl:stylesheet>
-- Geert.Josten@xxxxxxxxxxx IT-consultant at Daidalos BV, Zoetermeer (NL)
http://www.daidalos.nl/ tel:+31-(0)79-3316961 fax:+31-(0)79-3316464
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] no attributes outputed wh, Neville Thomas | Thread | Re: [xsl] no attributes outputed wh, Neville Thomas |
Re: [xsl] Sub total generation - f, Geert Josten | Date | RE: [xsl] Sub total generation - f, Srinivasan, Sundar |
Month |