RE: [xsl] no attributes outputed when chaining transformations

Subject: RE: [xsl] no attributes outputed when chaining transformations
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 16 Dec 2004 23:44:57 -0000
I can't see anything wrong with your code here (and I'm afraid I don't have
time to investigate in any depth for you.) See if you get the same effect
when you run it with Saxon. It _could_ be a problem with Xalan's
implementation of SAXTransformerFactory.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Neville Thomas [mailto:nthomas@xxxxxxxxx] 
> Sent: 16 December 2004 19:34
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] no attributes outputed when chaining 
> transformations
> 
> Michael Kay wrote:
> 
> >The problem could easily be some slip-up in the template 
> matching rules,
> >e.g. a phase-1 template rule being invoked when you intended 
> a phase-2 rule
> >to fire.
> >  
> >
> Here are my samples, do you see anything that might cause 
> this slip-up?
> 
> 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>

Current Thread