XSLT script to match pattern a particular element instance within a specific parent Complextype -
i have schema this:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema" elementformdefault="unqualified" attributeformdefault="unqualified" version="1.28.0"> <xsd:complextype name="accountsreceivableinfo_type"> <xsd:sequence> <xsd:element ref="sourceincomepct" minoccurs="0" maxoccurs="1"/> <xsd:element ref="duplicaterecordspct" minoccurs="0" maxoccurs="1"/> </xsd:sequence> <xsd:attribute name="id" type="id"/> <xsd:attribute name="locationref" type="idref"/> </xsd:complextype> <xsd:complextype name="accountsdeleteinfo_type"> <xsd:sequence> <xsd:element ref="sourceincomepct" minoccurs="0" maxoccurs="1"/> <xsd:element ref="duplicaterecordspct" minoccurs="0" maxoccurs="1"/> </xsd:sequence> <xsd:attribute name="id" type="id"/> <xsd:attribute name="locationref" type="idref"/> </xsd:complextype>
and trying modify , write xslt script to:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema" elementformdefault="unqualified" attributeformdefault="unqualified" version="1.28.0"> <xsd:complextype name="accountsreceivableinfo_type"> <xsd:sequence> <!--<xsd:element ref="sourceincomepct" minoccurs="0" maxoccurs="1"/>--> <xsd:element ref="duplicaterecordspct" minoccurs="0" maxoccurs="1"/> </xsd:sequence> <xsd:attribute name="id" type="id"/> <xsd:attribute name="locationref" type="idref"/> </xsd:complextype> <xsd:complextype name="accountsdeleteinfo_type"> <xsd:sequence> <xsd:element ref="sourceincomepct" minoccurs="0" maxoccurs="1"/> <xsd:element ref="duplicaterecordspct" minoccurs="0" maxoccurs="1"/> </xsd:sequence> <xsd:attribute name="id" type="id"/> <xsd:attribute name="locationref" type="idref"/> </xsd:complextype> xslt script wrote far <?xml version="1.0" encoding="utf-8" ?> <xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <xsl:output method="xml" encoding="utf-8" indent="yes"/> <xsl:template match="xsd:complextype[@name='accountsreceivableinfo_type'] /xsd:element[@ref ='sourceincomepct']"> <xsl:text disable-output-escaping="yes"><!--</xsl:text> <xsl:sequence select="."/> <xsl:text disable-output-escaping="yes">--></xsl:text> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy> </xsl:template> </xsl:transform>
what trying modify big schema above , automate , need read particular element within particular complextype parent , modify instance commenting out.
if want put element comment consider move xslt 3.0 , use
<xsl:template match="xsd:complextype[@name='accountsreceivableinfo_type']/xsd:sequence/xsd:element[@ref ='sourceincomepct']"> <xsl:comment select="serialize(.)"/> </xsl:template>
Comments
Post a Comment