Click here to Skip to main content
14,921,505 members
Home / Discussions / XML / XSL
   

XML / XSL

 
QuestionSpace in attribute name Pin
Anir19829-Nov-09 20:59
MemberAnir19829-Nov-09 20:59 
AnswerRe: Space in attribute name Pin
Stuart Dootson9-Nov-09 23:01
professionalStuart Dootson9-Nov-09 23:01 
AnswerRe: Space in attribute name Pin
tassilo10-Nov-09 23:06
Membertassilo10-Nov-09 23:06 
QuestionHow can I traverse and read values in an XML using VBScript? Pin
Curtis Rowell6-Nov-09 1:03
MemberCurtis Rowell6-Nov-09 1:03 
AnswerRe: How can I traverse and read values in an XML using VBScript? Pin
Stuart Dootson9-Nov-09 4:08
professionalStuart Dootson9-Nov-09 4:08 
QuestionXml File Problems Pin
md_refay4-Nov-09 4:19
Membermd_refay4-Nov-09 4:19 
AnswerRe: Xml File Problems Pin
The Man from U.N.C.L.E.11-Nov-09 11:45
MemberThe Man from U.N.C.L.E.11-Nov-09 11:45 
QuestionXSD Unique Implementation and XPath Pin
Skippums2-Nov-09 12:33
MemberSkippums2-Nov-09 12:33 
Firstly, if anyone could send me a link that explains everything that is allowed in XSD xpath expressions, I would be very grateful. I have searched for hours, and still have no idea what subset of xpath is allowed for either the selector or the field nodes. Great thanks to anyone who knows where I can find some documentation on this feature of xsd.

On to my problem... I am attempting to have an element, "parent", that contains a key attribute called "key". Every such element may have 0 or more child elements, called "Child", such that they contain a keyref attribute called "key" as well. I am wondering if there is a way to enforce through the XSD that the value of "key" for the child elements cannot be equivalent to the value of "key" for the parent node. So, for example:

<!-- XSD File -->
<xsd:element name="Example" type="ExampleType">
    <xsd:key name="ParentKey">
        <xsd:selector xpath="Parent"/>
        <xsd:field    xpath="@key"  />
    </xsd:key>
    <xsd:keyref name="ChildKeyRef" refer="ParentKey">
        <xsd:selector xpath="Parent/Child"/>
        <xsd:field    xpath="@key"        />
    </xsd:keyref>
</xsd:element>

<xsd:complexType name="ExampleType">
    <xsd:sequence>
        <xsd:element name="Parent" type="ParentType" maxOccurs="unbounded">
            <!-- This unique portion is where I need the help.  It almost works in that it prevents me from
                 giving a child element the parent's key, but it also has the unfortunate side effect of not
                 allowing me to have duplicate key references in the child elements.  How can this be done? -->
            <xsd:unique name="UniqueKeyRef">
                <xsd:selector xpath=".|Child"/>
                <xsd:field    xpath="@key"   />
            </xsd:unique>
        </xsd:element>
    </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="ParentType">
    <xsd:attribute name="key" type="xsd:String" use="required"/>
    <xsd:sequence>
        <xsd:element name="Child" type="ChildType" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="ChildType">
    <xsd:attribute name="key" type="xsd:String" use="required"/>
</xsd:complexType>

<-- XML File -->
<Example>
    <Parent key="A">
        <Child key="B"/>
        <Child key="B"/> <!-- This is allowed, since it references a different element than it's parent -->
                         <!-- This duplicate is currently not allowed even though I want it to be.      -->
        <Child key="A"/> <!-- This is NOT allowed, because this element is a child of Parent "A"        -->
    </Parent>
    <Parent key="B"/>
</Example>
Hopefully this example has clearly illustrated my desire. Any number of children of Parent "A" can reference any other parent, including multiple children referencing the same parent (such as the two child elements referencing parent "B" in my example). Is there some way to rework my unique constraint, or by adding another constraint, such that these duplicates are allowed? Thanks,

Sounds like somebody's got a case of the Mondays

-Jeff

modified on Tuesday, November 3, 2009 10:19 AM

AnswerRe: XSD Unique Implementation and XPath Pin
Christian Graus3-Nov-09 11:27
protectorChristian Graus3-Nov-09 11:27 
AnswerRe: XSD Unique Implementation and XPath Pin
Stuart Dootson3-Nov-09 22:54
professionalStuart Dootson3-Nov-09 22:54 
GeneralRe: XSD Unique Implementation and XPath Pin
Skippums4-Nov-09 2:28
MemberSkippums4-Nov-09 2:28 
GeneralRe: XSD Unique Implementation and XPath Pin
Stuart Dootson4-Nov-09 2:52
professionalStuart Dootson4-Nov-09 2:52 
QuestionSorted xml element while serialising Pin
Soundman32.22-Nov-09 1:28
MemberSoundman32.22-Nov-09 1:28 
AnswerRe: Sorted xml element while serialising Pin
Soundman32.22-Nov-09 3:58
MemberSoundman32.22-Nov-09 3:58 
Questionattribute centric Pin
Michael A. Klausmeyer1-Nov-09 8:27
MemberMichael A. Klausmeyer1-Nov-09 8:27 
QuestionHow to Password Protect a XML SpreadSheet Pin
ANSHUMAN44429-Oct-09 5:14
MemberANSHUMAN44429-Oct-09 5:14 
AnswerRe: How to Password Protect a XML SpreadSheet Pin
Christian Graus1-Nov-09 9:30
protectorChristian Graus1-Nov-09 9:30 
QuestionC# XML datagridview delete row Pin
Wheels01227-Oct-09 3:38
MemberWheels01227-Oct-09 3:38 
QuestionC# Append XML File Pin
Wheels01223-Oct-09 5:42
MemberWheels01223-Oct-09 5:42 
AnswerRe: C# Append XML File Pin
Christian Graus23-Oct-09 10:35
protectorChristian Graus23-Oct-09 10:35 
GeneralRe: C# Append XML File Pin
Wheels01226-Oct-09 1:24
MemberWheels01226-Oct-09 1:24 
QuestionIs it possible to call a comand line program from within an Xml File Preprocessor Pin
ONeil Tomlinson23-Oct-09 1:09
MemberONeil Tomlinson23-Oct-09 1:09 
AnswerRe: Is it possible to call a comand line program from within an Xml File Preprocessor Pin
Christian Graus23-Oct-09 10:44
protectorChristian Graus23-Oct-09 10:44 
QuestionXSL group [modified] Pin
Clas Andersson22-Oct-09 21:26
MemberClas Andersson22-Oct-09 21:26 
AnswerRe: XSL group Pin
tassilo10-Nov-09 23:02
Membertassilo10-Nov-09 23:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.