Announcement Announcement Module
Collapse
No announcement yet.
Using StaxEventItemReader and XStreamMarshaller for complex XMLs Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using StaxEventItemReader and XStreamMarshaller for complex XMLs

    Hi all,

    i am currently trying to read in quite complex xmls and am suffering from a couple of unsolved issues. The XML has different nodes (e.g. "stats_session", "map_info" or "team", some with child elements and /or attributes).

    Attachment

    This is, how my reader is currently configured:

    Code:
    <bean id="xmlSessionLogItemReader" class="org.springframework.batch.item.xml.StaxEventItemReader">
            <property name="fragmentRootElementName" value="stats_session" />
            <property name="unmarshaller" ref="xmlSessionLogMarshaller" />
        </bean>
    
        <bean id="xmlSessionLogMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
            <property name="aliases">
                <util:map id="aliases">
                    <entry key="stats_session" value="com.crytek.dwh.etl.sources.warface.domain.XmlSessionLog" />
                    <entry key="map_info" value="com.crytek.dwh.etl.sources.warface.domain.XmlSessionLogMapInfo" />
                    <entry key="team" value="com.crytek.dwh.etl.sources.warface.domain.XmlSessionLogTeam" />
                </util:map>
            </property>
            <property name="useAttributeFor">
                <util:map id="useAttributeFor">
                    <entry key="cpu_time_kernel">
                        <value type="java.lang.Class">com.crytek.dwh.etl.sources.warface.domain.XmlSessionLog</value>
                  </entry>
                </util:map>
            </property>
            <property name="omittedFields">
                <util:map id="omittedFields">
                    <entry key="com.crytek.dwh.etl.sources.warface.domain.XmlSessionLog" value="timelines,round" />
                    <entry key="com.crytek.dwh.etl.sources.warface.domain.XmlSessionLogMapInfo" value="sublevel" />
                    <entry key="com.crytek.dwh.etl.sources.warface.domain.XmlSessionLogTeam" value="timelines" />
                </util:map>
            </property>
        </bean>
    My questions now are:

    How do i achieve that XmlSessionLogMapInfo and XmlSessionLogTeam are injected into XmlSessionLog so i can use the latter's getter methods to retrieve those object?

    Also i am not yet sure how to retrieve the attributes (e.g. cpu_time_kernel").

    Sorry if my questions seem to be nonsense but i am still not too familiar with Spring / Spring Batch.

    Thanks in advance.
    Attached Files

  • #2
    The image is a little bit messed up...so here is an excerpt from the xml:

    <stats_session version="3" time="2012-06-07" gamemode="PVP" submode="FFA" difficulty="normal" masterserver="pvp_skilled_1" hostname="xxx.xxx.xxx.xxx" mem_usage_start="177999872" winner="-1" session_time="605" total_sent_udp="25322296" tota_recv_udp="20314192" total_sent_tcp="206097" total_recv_tcp="35662" mem_usage_end="177852416" cpu_time_user="6.950195" cpu_time_kernel="1.369995">
    <map_info name="@pvp_mission_display_name_ffa_forest" uid="45e182f3-d45c-4e5d-8054-fc4bbbfc2042" path="levels/pvp/ffa_forest" sublevels="0" />
    <timelines></timelines>
    <round>
    <player></player>
    <player></player>
    <player></player>
    <player></player>
    <player></player>
    <player></player>
    <player></player>
    </round>
    </stats_session>

    Comment

    Working...
    X