You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by "Petetsky, Alexander" <pe...@aware.com> on 2007/04/10 16:58:00 UTC

issue with set[Element] method

Hi. I am stuck dealing with a problem and hope someone can help me.
I have an XML file that I manipulate with XmlBeans(see schema below).
The process is as follows:
I get a XML file that lists one or more profiles by name and I need to return the same XML with ProfileContent populated for each profile(ProfileContents are stored in the separate files). When I do so (code below) I end up with nested ProfileContent elements. WHAT AM I DOING WRONG?

Alex Petetsky

XML IN:
<Utilities xmlns="http://my.comp.com/myschema.xsd">
  <Profiles>
    <Profile>
      <Name>Adsl2_pr</Name>
    </Profile>
  </Profiles>
</Utilities>

PROCESS CODE:
      public String processXml(String inxml, ProfileManager mgr){
	UtilitiesDocument utilIn = UtilitiesDocument.Factory.parse(inxml);
            UtilitiesClassType top = utilIn.getUtilities();
            ProfilesTypeConfig[] aProfiles = top.getProfilesArray();
            for (ProfilesTypeConfig profiles : aProfiles) {
                for (ProfileTypeConfig profile : profiles.getProfileArray()) {
                    String pName = profile.getName();
                    String pContent = mgr.getProfile(pName);
                    ProfileContentClassType pcontent = ProfileContentClassType.Factory.parse(pContent);
                    profile.setProfileContent(ic);
                }
            }
            return utilIn.xmlText(new XmlOptions().setSavePrettyPrint());
       }

XML OUT:
<Utilities xmlns="http://my.comp.com/myschema.xsd">
  <Profiles>
    <Profile>
      <Name>Adsl2_pr</Name>
      <ProfileContent>
        <ProfileContent>
          <LoopEstimates>
            <EstimatedLinks>
              <Scenarios>
                <Scenario>
                  <Name>ADSL1</Name>
                  <LinkProfile>
                    <DslStandard>G.992.1 Annex A</DslStandard>
                    <Upstream>
                      <MaxInterleavingDelay>
                        <PhysicalUnits>ms</PhysicalUnits>
                        <Value>1</Value>
                      </MaxInterleavingDelay>
                    </Upstream>
                    <Downstream>
                      <MaxInterleavingDelay>
                        <PhysicalUnits>ms</PhysicalUnits>
                        <Value>1</Value>
                      </MaxInterleavingDelay>
                    </Downstream>
                  </LinkProfile>
                  <Noise>
                    <Downstream>
                      <NearEnd>
                        <Models>
                          <WhiteNoise>
                            <PhysicalUnits>dBm/Hz</PhysicalUnits>
                            <Value>-140.0</Value>
                          </WhiteNoise>
                        </Models>
                      </NearEnd>
                    </Downstream>
                    <Upstream>
                      <NearEnd>
                        <Models>
                          <WhiteNoise>
                            <PhysicalUnits>dBm/Hz</PhysicalUnits>
                            <Value>-140.0</Value>
                          </WhiteNoise>
                        </Models>
                      </NearEnd>
                    </Upstream>
                  </Noise>
                  <ResultsReporting>
                    <Upstream>
                      <BitAllocation>
                        <IsReported>true</IsReported>
                      </BitAllocation>
                    </Upstream>
                    <Downstream>
                      <BitAllocation>
                        <IsReported>true</IsReported>
                      </BitAllocation>
                    </Downstream>
                  </ResultsReporting>
                </Scenario>
              </Scenarios>
            </EstimatedLinks>
          </LoopEstimates>
        </ProfileContent>
      </ProfileContent>
    </Profile>
  </Profiles>
</Utilities>

SCHEMA:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="myid"
           targetNamespace="http://my.comp.com/myschema.xsd"
           version="1.0.0.1"
           elementFormDefault="qualified"
           attributeFormDefault="qualified"
           xmlns="http://my.comp.com/myschema.xsd"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Utilities" type="UtilitiesClassType"/>
<xs:complexType name="UtilitiesClassType">
        <xs:choice>
            ...
            <xs:element name="Profiles" type="ProfilesTypeConfig" minOccurs="0" maxOccurs="unbounded"/>
	...
        </xs:choice>
    </xs:complexType>
    <xs:complexType name="ProfilesTypeConfig">
        <xs:sequence>
            <xs:element name="Profile" type="ProfileTypeConfig" minOccurs="1" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="ProfileTypeConfig">
        <xs:all>
            <xs:element name="Name" type="xs:string" minOccurs="1"/>
            <xs:element name="ProfileContent" type="ProfileContentClassType" minOccurs="0"/>
        </xs:all>
    </xs:complexType>
    <xs:complexType name="ProfileContentClassType">
        <xs:all>
            <xs:element name="Action" type="xs:string" minOccurs="0"/>
            <xs:element name="ReferencedObjects" type="ReferencedObjectsClassType" minOccurs="0"/>
            <xs:element name="PhysicalUnits" type="PhysicalUnitsClassType" minOccurs="0"/>
            <xs:element name="Temperature" type="TemperaturePudValue" minOccurs="0"/>
            <xs:element name="LoopEstimates" type="LoopEstimatesConfigClassType" minOccurs="0"/>
            <xs:element name="ActualLink" type="ActualLinkInterpConfigClassType" minOccurs="0"/>
            <xs:element name="SpectralAnalyses" type="SpectralAnalysesConfigClassType" minOccurs="0"/>
            <xs:element name="LinkCharacterization" type="LinkCharacterizationClassType" minOccurs="0"/>
            <xs:element name="SeltPmdCalibration" type="SeltPmdCalibrationClassType" minOccurs="0"/>
            <xs:element name="CapacitancePerUnitLength" type="PudValue" minOccurs="0"/>
            <xs:element name="GenericAutomatedLoopTest" type="MeltGenericAutomatedLoopTestClassType" minOccurs="0"/>
        </xs:all>
    </xs:complexType>
...
</xs:schema>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org