[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: no attributes outputed when chaining transformatio
Andrew Welch wrote:
Not much to go on here, but it could be that if you generating SAX events from the result of A->B for the input of transformation C, you are creating a new AttributesImpl() object instead of using the existing object (typically 'atts') in the startElement() call. It would be less wild speculaton if you posted the method that chains the transforms :) Thanks for the relpy guys, becuase my files were very large I was reluctant to post them. I have sinced reduced them in size to illustrate my challenge (see below). Jarno I am using Xalan-J-2.6.0 and I have not tried any other XSLT engine. And Michael I am very new to XSL, the stylesheets themselves were generated with Altova Mapforce. The java code I use to illustrate below is a modification of the Xalan UseXMLFilters sample. ****Java Code *****: 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*********** <?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" 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> <!--xsl:attribute name="schemaversion"> <xsl:value-of select="$tpVersion"/> </xsl:attribute--> <xsl:for-each select="@federationName"> <xsl:attribute name="federationName"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="@fedFile"> <xsl:attribute name="fedFile"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="@ridFile"> <xsl:attribute name="ridFile"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="@rtiExecArgs"> <xsl:attribute name="rtiExecArgs"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="@rtiHome"> <xsl:attribute name="rtiHome"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="@rtiBuildType"> <xsl:attribute name="rtiBuildType"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="@hlaControlDir"> <xsl:attribute name="hlaControlDir"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="n12:preTestPlanCommand"> <preTestPlanCommand> <xsl:value-of select="."/> </preTestPlanCommand> </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:attribute name="schemaversion"> <xsl:value-of select="$tpVersion"/> </xsl:attribute--> <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> <xsl:for-each select="@fedFile"> <xsl:attribute name="fedFile"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="@ridFile"> <xsl:attribute name="ridFile"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="@rtiExecArgs"> <xsl:attribute name="rtiExecArgs"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="@rtiHome"> <xsl:attribute name="rtiHome"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="@rtiBuildType"> <xsl:attribute name="rtiBuildType"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="@hlaControlDir"> <xsl:attribute name="hlaControlDir"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="@hlaResultsDir"> <xsl:attribute name="hlaResultsDir"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="@hlaResultsHost"> <xsl:attribute name="hlaResultsHost"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="@hlaEvalDir"> <xsl:attribute name="hlaEvalDir"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="@hlaEvalHost"> <xsl:attribute name="hlaEvalHost"> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> </testPlan> </xsl:template> </xsl:stylesheet>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|