c# - Create XSLT for XML from XML -


i have convert xml xml through xsl. have following xml

<?xml version="1.0" encoding="utf-8"?><skos xmlns="http://www.w3.org/2004/02/skos/core#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:skosxl="http://www.w3.org/2008/05/skos-xl#">     <skos:descriptor id="7769" tagno="111" isvalid="true">         <skos:altlabel>abyssinian expedition (1867-1868)</skos:altlabel>         <skos:preflabel>abyssinian expedition (1867-1868)</skos:preflabel>         <skos:broader>ethiopia -- history -- 1490-1889</skos:broader>         <skos:broader>great britain -- history -- victoria, 1837-1901</skos:broader>         <skosxl:hiddenlabel>expedition abyssinia (1867-1868)</skosxl:hiddenlabel>         <skosxl:hiddenlabel>british expedition abyssinia (1867-1868)</skosxl:hiddenlabel>         <skosxl:hiddenlabel>magdala campaign, 1867-1868</skosxl:hiddenlabel>         <skosxl:hiddenlabel>napier expedition, 1867-1868</skosxl:hiddenlabel>     </skos:descriptor> </skos> 

and want output this

<add> <doc>     <field name="id">7769</field>     <field name="tagno">111</field>     <field name="altlabel">abyssinian expedition (1867-1868)</field>     <field name="broader">ethiopia -- history -- 1490-1889</field>     <field name="broader">great britain -- history -- victoria, 1837-1901</field>     <field name="hiddenlabel">expedition abyssinia (1867-1868)</field>     <field name="hiddenlabel">british expedition abyssinia (1867-1868)</field>     <field name="hiddenlabel">magdala campaign, 1867-1868</field>     <field name="hiddenlabel">napier expedition, 1867-1868</field>  </doc> 

i not getting how make xslt of it.

you have provided no explanation how input results in output (e.g. why there no isvalid field in output? isvalid relevant process or should ignored? why there no preflabel field in output?), produce output described:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"                 xmlns:skos="http://www.w3.org/2004/02/skos/core#"                 exclude-result-prefixes="skos"                >   <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>    <xsl:template match="/*">     <add>       <xsl:apply-templates select="skos:descriptor" />     </add>   </xsl:template>    <xsl:template match="skos:descriptor">     <doc>       <field name="id">         <xsl:value-of select="@id"/>       </field>       <xsl:apply-templates select="@*[not(name() = 'id' or name() = 'isvalid')] |                                     *[not(self::skos:preflabel)]" />     </doc>   </xsl:template>    <xsl:template match="@* | *">     <field name="{local-name()}">       <xsl:value-of select="." />     </field>   </xsl:template> </xsl:stylesheet> 

when run on sample input, result is:

<add>   <doc>     <field name="id">7769</field>     <field name="tagno">111</field>     <field name="altlabel">abyssinian expedition (1867-1868)</field>     <field name="broader">ethiopia -- history -- 1490-1889</field>     <field name="broader">great britain -- history -- victoria, 1837-1901</field>     <field name="hiddenlabel">expedition abyssinia (1867-1868)</field>     <field name="hiddenlabel">british expedition abyssinia (1867-1868)</field>     <field name="hiddenlabel">magdala campaign, 1867-1868</field>     <field name="hiddenlabel">napier expedition, 1867-1868</field>   </doc> </add> 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -