Subject: RE: [xsl] Using a template to transform a node attribute From: "Emerson, Matt" <Matt.Emerson@xxxxxxx> Date: Mon, 12 Sep 2005 11:40:57 -0400 |
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: [xsl] 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 ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Create two xml files from, Michael Kay | Thread | Re: [xsl] Using a template to trans, David Carlisle |
Re: [xsl] Using a template to trans, Will McCutchen | Date | Re: [xsl] Using a template to trans, David Carlisle |
Month |