문제

I got an DTD and XML file. The DTD contains an id attribute on a element. What I wondering about is, if I open the file in my xml-editor(XMetaL), then insert a new element.
Can the DTD somehow generate an random id for the id attribute or maybe the XML fil can generate this?

Thanks!

도움이 되었습니까?

해결책

The DTD will define the type of the ID attribute (quite probably of type ID so as to indicate it must follow XML rules for IDs, though just because an attribute is called id doesn't mean it's type will be ID).

An XML editor could have the ability to add a value that followed this by generating a string that doesn't match any current ID (e.g. elname1, elname2, etc.) but this would have to be a feature of the editor, not something specified by the DTD itself.

(There is comparable—"comparable" as they are not XML files though they have some similarities—functionality in many IDEs for dealing with ASP.NET, where it would add e.g. id="repeater1" and so on. Personally I find this more of a nuisance than a boon).

다른 팁

XML is just a structure that represents Data. DTD is the definition of you xml structure. Non of these are generating ids for you.

However XSLT's generate-id() will be suitable for you. You can learn more from w3c http://www.w3schools.com/xsl/func_generateid.asp

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top