1<?xml version='1.0'?> 2 3<xsl:stylesheet 4 5 version='1.0' 6 7 xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> 8 9 10 11<!-- Description: Differentiates a simple polynomial function --> 12 13<!-- Author: Charlie Halpern-Hamu, Ph.D. --> 14 15<!-- Reference: http://www.incrementaldevelopment.com/papers/xsltrick/#differentiate --> 16 17 18 19<xsl:strip-space elements='*'/> 20 21 22 23<xsl:output 24 25 method='xml' 26 27 indent='yes'/> 28 29 30 31<xsl:template match='/function-of-x'> 32 33<xsl:element name='function-of-x'> 34 35<xsl:apply-templates select='term'/> 36 37</xsl:element> 38 39</xsl:template> 40 41 42 43<xsl:template match='term'> 44 45<term> 46 47<coeff> 48 49<xsl:value-of select='coeff * power'/> 50 51</coeff> 52 53<x/> 54 55<power> 56 57<xsl:value-of select='power - 1'/> 58 59</power> 60 61</term> 62 63</xsl:template> 64 65 <!-- 66 * Licensed to the Apache Software Foundation (ASF) under one 67 * or more contributor license agreements. See the NOTICE file 68 * distributed with this work for additional information 69 * regarding copyright ownership. The ASF licenses this file 70 * to you under the Apache License, Version 2.0 (the "License"); 71 * you may not use this file except in compliance with the License. 72 * You may obtain a copy of the License at 73 * 74 * http://www.apache.org/licenses/LICENSE-2.0 75 * 76 * Unless required by applicable law or agreed to in writing, software 77 * distributed under the License is distributed on an "AS IS" BASIS, 78 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 79 * See the License for the specific language governing permissions and 80 * limitations under the License. 81 --> 82 83</xsl:stylesheet> 84