[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Using a template to transform a node attribute
Hi David, When I tried your solution, I got the following error: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: Use "<" for "<" in attribute values. javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: Use "<" for "<" in attribute values. at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(Transfo rmerFactoryImpl.java:805) There must be an easy way of doing this. Do you have any other ideas? Matt -----Original Message----- From: David Carlisle [mailto:davidc@xxxxxxxxx] Sent: Monday, September 12, 2005 11:33 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: Using a template to transform a node attribute > But the parser tells me that I have a syntax error when trying to > specify the attribute "id" properly. Any ideas? It shouldn't be the parser (It's not a syntax error) You should have (most likely) got a run time error saying that you could not generate an attribute node (it depends on the rest of your template that you didn't show). <xsl:template match="/report/version[@id]"> does not match id attributes it matches version elements that have an id. <xsl:attribute name="id">bar</xsl:attribute> then generates an id attribute but you may only do this if you have not already started to generate child elements or text of the parent element. Probably you want something like <xsl:template match="*|@*"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="version/@id"> <xsl:attribute name="id">bar</xsl:attribute> </xsl:template> David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
|
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
|