Kevin Goodman Posted April 13, 2006 Share Posted April 13, 2006 I'm trying to perform a xsl:copy of a xml file and re-format a couple of attribute contents. From what I've read and the examples I've seen I've been able to make the copy but its not applying or matching my templates. I'm running from a Java app and I get a xml output file and I get no errors. But the contents is the same as the original. Any pointers are appreciated. Here is the xsl file. <?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:xsd="http://www.w3.org/2001/XMLSchema"xmlns:AG="http://support.agile.com/misc/axml/2005/11/"xmlns="http://www.w3.org/TR/html4"xsi:schemaLocation="http://support.agile.com/misc/axml/2004/12/ http://support.agile.com/misc/axml/2004/12/"><xsl:output method="html"/> <!-- Whenever you match any node or any attribute --> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates/> <!-- select="@*|node()" --> </xsl:copy> </xsl:template> <xsl:template match="Description"> <xsl:element name="Description"> <xsl:variable name="Desc" select="substring(AG:TitleBlock/AG:Description, 1, 36)"/> <xsl:variable name="DescUpper" select="xsl:upper-case($Desc)"/> <xsl:value-of select="$DescUpper"/> </xsl:element> </xsl:template> <xsl:template match="Rev"> <xsl:element name="Rev"> <xsl:variable name="revision" select="AG:TitleBlock/AG:Rev" /> <xsl:value-of select="substring-before($revision, ' ')"/> </xsl:element> </xsl:template></xsl:stylesheet> Link to comment Share on other sites More sharing options...
boen_robot Posted April 14, 2006 Share Posted April 14, 2006 Try to add <xsl:template match="/"><xsl:apply-templates/></xsl:template> The match of "/" is usually the piece needed to invoke the rest of the templates by the apply-templates elements.If this doesn't help, could you please provide a sample XML. I seem to be unable to get used to your schema, so if you have a sample valid XML file, this would help the investigation . Link to comment Share on other sites More sharing options...
Kevin Goodman Posted April 17, 2006 Author Share Posted April 17, 2006 I'm trying to perform a xsl:copy of a xml file and re-format a couple of attribute contents. From what I've read and the examples I've seen I've been able to make the copy but its not applying or matching my templates. I'm running from a Java app and I get a xml output file and I get no errors. But the contents is the same as the original. Any pointers are appreciated. Here is the xsl file. <?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:xsd="http://www.w3.org/2001/XMLSchema"xmlns:AG="http://support.agile.com/misc/axml/2005/11/"xmlns="http://www.w3.org/TR/html4"xsi:schemaLocation="http://support.agile.com/misc/axml/2004/12/ http://support.agile.com/misc/axml/2004/12/"><xsl:output method="html"/> <!-- Whenever you match any node or any attribute --> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates/> <!-- select="@*|node()" --> </xsl:copy> </xsl:template> <xsl:template match="Description"> <xsl:element name="Description"> <xsl:variable name="Desc" select="substring(AG:TitleBlock/AG:Description, 1, 36)"/> <xsl:variable name="DescUpper" select="xsl:upper-case($Desc)"/> <xsl:value-of select="$DescUpper"/> </xsl:element> </xsl:template> <xsl:template match="Rev"> <xsl:element name="Rev"> <xsl:variable name="revision" select="AG:TitleBlock/AG:Rev" /> <xsl:value-of select="substring-before($revision, ' ')"/> </xsl:element> </xsl:template></xsl:stylesheet><{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
Kevin Goodman Posted April 17, 2006 Author Share Posted April 17, 2006 Actually, this is from an example of how to copy elements and data where the element is a node or an attribute. Link to comment Share on other sites More sharing options...
boen_robot Posted April 17, 2006 Share Posted April 17, 2006 This doesn't make much difference you know. Sample XMLs are essential in order to see what happens to what. I don't have experience with the xsl:copy element, but I don't think I can't without some kind of proper XML for the XSLT to transform. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now