c# - How to select an attribute value in an XML and concatenate it with a string and use it as an attribute value in a new XML using XSLT -


i need transform existing xml xml using xslt.

the problem facing need use "typename" attribute ecclass , concatenate http://www.semanticweb.org/aman.prasad/ontologies/2015/5/untitled-ontology-1#

the xml working -

<ecschema>     <ecclass typename="abc">         <baseclass>pqr</baseclass>         <baseclass>xyz</baseclass>     </ecclass>     <ecclass typename="ijk">         <baseclass>mno</baseclass>         <baseclass>def</baseclass>     </ecclass> <ecschema> 

for example concatenated result should -

http://www.semanticweb.org/aman.prasad/ontologies/2015/5/untitled-ontology-1#abc first ecclass

i need set string attribute value of rdf:about in owl:class tag in new xml structure.

the new xml structure -

<owl:ontology rdf:about="http://www.semanticweb.org/aman.prasad/ontologies/2015/5/untitled-ontology-1">     <owl:class rdf:about="http://www.semanticweb.org/aman.prasad/ontologies/2015/5/untitled-ontology-1#abc">     </owl:class>     <owl:class rdf:about="http://www.semanticweb.org/aman.prasad/ontologies/2015/5/untitled-ontology-1#abc">     </owl:class> </owl:ontology> 

right have not yet tried baseclass. have been trying convert ecclass owl:class.

the xsl -

<xsl:template match="/">      <owl:ontology rdf:about="http://www.semanticweb.org/aman.prasad/ontologies/2015/5/untitled-ontology-1"/>      <xsl:for-each select="ecschema/ecclass">         <owl:class rdf:about="<xsl:value-of select="concat('http://www.semanticweb.org/aman.prasad/ontologies/2015/5/untitled-ontology-1#' , '@typename') />" >         </owl:class>     </xsl:for-each>  </xsl:template> 

i have been trying many combinations various sources haven't been able it.

it returns error - "additional information: '<', hexadecimal value 0x3c, invalid attribute character."

can please me new xslt , have been getting lots of errors.

tags cannot nested. achieve purpose, should learn attribute value templates. in addition, code rather sloppy. try way:

<xsl:template match="/">     <owl:ontology rdf:about="http://www.semanticweb.org/aman.prasad/ontologies/2015/5/untitled-ontology-1">         <xsl:for-each select="ecschema/ecclass">             <owl:class rdf:about="{concat('http://www.semanticweb.org/aman.prasad/ontologies/2015/5/untitled-ontology-1#', @typename)}" />         </xsl:for-each>     </owl:ontology> </xsl:template> 

or perhaps bit more elegant:

<xsl:variable name="myurl">http://www.semanticweb.org/aman.prasad/ontologies/2015/5/untitled-ontology-1</xsl:variable>  <xsl:template match="/">     <owl:ontology rdf:about="{$myurl}">         <xsl:for-each select="ecschema/ecclass">             <owl:class rdf:about="{$myurl}#{@typename}" />         </xsl:for-each>     </owl:ontology> </xsl:template> 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -