[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: no attributes outputed when chaining transformatio

Subject: Re: no attributes outputed when chaining transformations
From: Geert Josten <Geert.Josten@xxxxxxxxxxx>
Date: Thu, 16 Dec 2004 20:27:19 +0100
xsl for each select
Hi Andrew,

Have you tried removing all the for-each's and replace them by:

<xsl:copy-of select="@*" />

or something like:

<xsl:apply-templates select="@*" />

and below the xsl:template:

  <xsl:template match="@*">
    <xsl:attribute name="{local-name()}">
      <xsl:value-of select="." />
    </xsl:attribute>
  </xsl:template>

I noticed that your input file uses a default namespace. Though you use a namespace with the testPlan element, you do not use it for accessing the attributes. Might help as well..

Cheers,
Geert

Neville Thomas wrote:

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>



Kindly Nev




-- Geert.Josten@xxxxxxxxxxx IT-consultant at Daidalos BV, Zoetermeer (NL)

http://www.daidalos.nl/
tel:+31-(0)79-3316961
fax:+31-(0)79-3316464

GPG: 1024D/12DEBB50

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.