Click here to Skip to main content
15,850,750 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
using xsd.exe tool to create XML Schema (XSD) for the following file


by xsd.exe and \dataset option , or drag xsd file directly in solution explorer and write this code
Time t = new Time();

error meassage appear when using dataset for this xsd schema
The same table 'Name' cannot be the child table in two nested relations.

how can i solve this problem ?
I want to handle this schema without
change "name" element to "hourName" and "dayName" for example or change "number" element to attribute,since another program (not open source) take generated XML file to deal with.
Updated 20-Oct-17 0:39am

1 solution

You could rename the nodes with XSLT and then read it in, and then rename them back when writing the output.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=""
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
    <xsl:output method="xml" indent="yes"/>

  <xsl:template match="*">
    <xsl:param name="parentElm">
      <xsl:value-of select="name(..)" />
      <xsl:when test="local-name() = 'Name'">
        <xsl:element name="{concat('Name',$parentElm)}">
          <xsl:apply-templates select="@* | node()" />
        <xsl:element name="{local-name()}">
          <xsl:copy-of select="@*" />
          <xsl:apply-templates select="@* | node()" />

I took the XSLT example from here:[^]
Share this answer
ibrahim_ragab 20-Mar-13 10:45am    
thanks very much
but how can I use xslt file in C# code?
and how can I generate it for large xml that contain hundred of conversions(edit in visual studio text editor will be hard)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900