路径/节点顺序
问题描述:
有没有人有关于如何在XSD深一横 跟踪的路径,例如一个想法:如果我有这个模式,路径/节点顺序
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:books" xmlns:bks="urn:books">
<xsd:element name="books" type="bks:BooksForm"/>
<xsd:complexType name="BooksForm">
<xsd:sequence>
<xsd:element name="book" type="bks:BookForm" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="BookForm">
<xsd:sequence>
<xsd:element name="author" type="xsd:string"/>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="genre" type="xsd:string"/>
<xsd:element name="price" type="xsd:float" />
<xsd:element name="pub_date" type="xsd:date" />
<xsd:element name="review" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string"/>
</xsd:complexType>
</xsd:schema>
我怎么能得到像在C#中
path1 : books.book.author
path2 : books.book.title
此输出..等等
任何模式结构
没有任何人有一个想法,这个或任何良好的出发点 由于事先
感谢答复 我试图编写你的意见,但我仍然陷入
while (r.Read())
{
switch (r.Name)
{
case "xsd:element":
myStringBuilder.Append(r.GetAttribute("name"));
break;
case "xsd:complexType":
checkComplex(r);
wholepath += r.GetAttribute("name");
//this will only concatenate complex elements only
Console.WriteLine("checkComplexcaller{1}", wholepath);
break;
}
}
递归部分..我没有
public static void checkComplex(/*what I should send here*/)
{
if (r.GetAttribute("name") == "xsd:complexType")
{
//What I sould to do for this recursive
}
else if (r.GetAttribute("name") == "xsd:element")
{
myStringBuilder.Append(r.GetAttribute("name"));
}
}
怎么可能设置的路径正确
答
如果我得到这个权利:(伪)
(make a xml document of the xsd)
foreach node of type xsd:element:
track path to the node as input
apend it with values of 'name' and 'type' attributes
if its a complex type: apply this recursively on all elements
我试图代码什么也建议我,但我被陷在某些方面 – Dena 2011-01-14 10:06:59