Subject: RE: [xsl] questions From: "Michael Kay" <mhkay@xxxxxxxxxxxx> Date: Thu, 13 Sep 2001 09:24:31 +0100 |
> I am attempting to write a diff-patch tool for xml. > I plan to do the patching work using using xsl. Remember that XSLT creates a new file, it doesn't modify the original. So your terminology is wrong, you can't "delete an attribute", all you have to do is to abstain from copying it. > As a part of this i have some questions... Let's assume you are doing the background copying with an identity template rule such as <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> Then you need to define additional template rules to handle nodes where different action is reuqired > > 1. How do change the name-value pair of an attribute using xsl? <xsl:template match="@price"> <xsl:attribute name="cost"> <xsl-value-of select="."/> </xsl:attribute> </xsl:template> > 2. How do i completely delete a attribute using xsl? <xsl:template match="@price"/> > 3. How do i add a attribute using xsl? <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:attribute name="currency">dollars</xsl:attribute> <xsl:apply-templates/> </xsl:copy> </xsl:template>> > > for eg consider an input xml in the form > > <book author="Lippman" price="20"> > </book> > > If decide to change the attribute price to cost the xml > should look like.. > <book author="Lippman" cost="20"> > </book> > > if i delete the attribute price the xml after transformation > should look > like > <book author="Lippman" > > </book> > > if i add a new attribute say currency the xml after > transformation should > look like > <book author="Lippman" price="20" currency="Dollars"> > </book> > > Regards > Mihir > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] questions, Mihir D. Gore | Thread | [xsl] Performance, Richard Mitchell |
[xsl] questions, Mihir D. Gore | Date | RE: [xsl] XSL Javascript prob, Chris Bayes |
Month |