Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create structured tags in XML schema?

Status
Not open for further replies.

chandimapa

Programmer
Mar 6, 2006
2
CA
Hi there,

I have an XML file with a grouped <employee> tags like,

<employee>
<employeename>John</employeename>
<employeename>Dave</employeename>
</employee>

I want to structure above xml file to be like this

<employee>
<employeename>John</employeename>
</employee>

<employee>
<employeename>Dave</employeename>
</employee>

Can I do that in a XML schema (.xsd file)? If I can, how do I do that?

Thanks,
Chandi
 
>Can I do that in a XML schema (.xsd file)?
I don't think it is the job of schema file to create anything for the xml file. It is the job of transformation xslt.
 
Yes, XML schema defines what the structure of an XML document should be. XSL transforms XML documents, so this is what you need.

To do what you want, you'd have to do something like:
Code:
<xsl:template match="employee">
  <xsl:apply-templates select="employeename"/>
</xsl:template>
<xsl:template match="employeename">
  <employee>
    <name>
      <xsl:value-of select="."/>
    </name>
  </employee>
</xsl:template>

Jon

"I don't regret this, but I both rue and lament it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top