Hi all,

I need to translate my xml data to a new XML file wuth XSLT. I thought I had it, but I only got first row.

Need help to write the XSLT.


I have XML data exported from access: (using XSLT - to get my file)

- <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="gre.xsd" generated="2011-03-13T22:08:05">
- <gre>
<ARTNR>A12/640</ARTNR>
<Aktuellt>2</Aktuellt>
</gre>
- <gre>
<ARTNR>BD2000</ARTNR>
<Aktuellt>5</Aktuellt>
</gre>
- <gre>
<ARTNR>BD2005</ARTNR>
<Aktuellt>7</Aktuellt>
</gre>
- <gre>
<ARTNR>BD3100</ARTNR>
<Aktuellt>1</Aktuellt>
</gre>
- <gre>
<ARTNR>BD4000</ARTNR>
<Aktuellt>1</Aktuellt>
</gre>
</dataroot>


Need to get <artnr> and <aktuellt> data in the "row element" - to this get a xml like this xml:

<?xml version="1.0" encoding="ISO-8859-1" ?>
- <xmlimexport>
- <customers>
<atKunder key="100" option="noedit" />
</customers>
- <orders>
- <order>
- <atOrder customerkey="100">
<OOI_HEAD_CUSTOMER_NUMBER>100</OOI_HEAD_CUSTOMER_NUMBER>
</atOrder>
- <rows>
- <row>
<OOI_ROW_ARTICLE_NUMBER>A12/640H9700</OOI_ROW_ARTICLE_NUMBER>
<OOI_ROW_QUANTITY2>2</OOI_ROW_QUANTITY2>
</row>
- <row>
<OOI_ROW_ARTICLE_NUMBER>BD2000</OOI_ROW_ARTICLE_NUMBER>
<OOI_ROW_QUANTITY2>5</OOI_ROW_QUANTITY2>

**All data from xml**

</row>
</rows>
</order>
</orders>
</xmlimexport>


Im's sute you know to writ ths XSLT correct.

Thank you for the help.

xml1 is connected with xml2?

the whole is not described well

please more information and the result
better describe

I konw my english is bad - But it might be better than your swedish :)

I export data from Access to XML. The XML file then look like this:


- <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="gre.xsd" generated="2011-03-13T22:08:05">
- <gre>
<ARTNR>A12/640</ARTNR>
<Aktuellt>2</Aktuellt>
</gre>
- <gre>
<ARTNR>BD2000</ARTNR>
<Aktuellt>5</Aktuellt>
</gre>
...

To Imort this file in another program I need to have specific tags. Then I need to add a XSLT to the export to get the specified format for another program.

I will give all tags constand data exept for the tag "OOI_ROW_ARTICLE_NUMBER" and "OOI_ROW_QUANTITY2" where I need to get the data from the Access-data. <ARTNR> and <Aktuellt>

I will give this some more time and maybe solve it, but a first litte help would be great. Lot od information to make XSLT with HTLM but not so much how to make XSLT to "translate" a XML-file.

Sorry again for my english. Kan du svenska så är det lite lättare :)

Edited 5 Years Ago by nip: n/a

Hello
I would like an xml with data that is

and then the result after the transformation

the first question as it looked the last two XML files

the data do not match

I speak German else my english is bad

Hej
Jag skulle vilja ha ett XML med data som

och sedan resultatet efter omvandlingen

i den första frågan som den såg ut de senaste två XML-filer

uppgifterna stämmer inte

Jag talar tyska annan Min engelska är dålig

Jag vet inte var de kommer ifrån data
xml

<?xml version="1.0"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="gre.xsd" generated="2011-03-13T22:08:05">
	<gre>
		<ARTNR>A12/640</ARTNR>
		<Aktuellt>2</Aktuellt>
	</gre>
	<gre>
		<ARTNR>BD2000</ARTNR>
		<Aktuellt>5</Aktuellt>
	</gre>
	<gre>
		<ARTNR>BD2005</ARTNR>
		<Aktuellt>7</Aktuellt>
	</gre>
	<gre>
		<ARTNR>BD3100</ARTNR>
		<Aktuellt>1</Aktuellt>
	</gre>
	<gre>
		<ARTNR>BD4000</ARTNR>
		<Aktuellt>1</Aktuellt>
	</gre>
</dataroot>

xsl

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output indent="yes" method="xml"/>
	<xsl:template match="/">
		<xmlimexport>
			<customers>
				<!-- I know not where they come from data -->
				<atKunder key="100" option="noedit"/>
				<xsl:apply-templates select="dataroot"/>
			</customers>
		</xmlimexport>
	</xsl:template>
	<xsl:template match="dataroot">
		<orders>
			<order>
                                <!-- I know not where they come from data -->
				<atOrder customerkey="100">					                                                                <OOI_HEAD_CUSTOMER_NUMBER>100</OOI_HEAD_CUSTOMER_NUMBER>
				</atOrder>
				<rows>
					<xsl:apply-templates select="gre"/>
				</rows>
			</order>
		</orders>
	</xsl:template>
	<xsl:template match="gre">
		<row>
			<OOI_ROW_ARTICLE_NUMBER>
				<xsl:value-of select="ARTNR"/>
			</OOI_ROW_ARTICLE_NUMBER>
			<OOI_ROW_QUANTITY2>
				<xsl:value-of select="Aktuellt"/>
			</OOI_ROW_QUANTITY2>
		</row>
	</xsl:template>
</xsl:stylesheet>

result

<?xml version='1.0' ?>
<xmlimexport>
  <customers>
    <atKunder key="100" option="noedit"/>
    <orders>
      <order>
        <atOrder customerkey="100">
          <OOI_HEAD_CUSTOMER_NUMBER>100</OOI_HEAD_CUSTOMER_NUMBER>
        </atOrder>
        <rows>
          <row>
            <OOI_ROW_ARTICLE_NUMBER>A12/640</OOI_ROW_ARTICLE_NUMBER>
            <OOI_ROW_QUANTITY2>2</OOI_ROW_QUANTITY2>
          </row>
          <row>
            <OOI_ROW_ARTICLE_NUMBER>BD2000</OOI_ROW_ARTICLE_NUMBER>
            <OOI_ROW_QUANTITY2>5</OOI_ROW_QUANTITY2>
          </row>
          <row>
            <OOI_ROW_ARTICLE_NUMBER>BD2005</OOI_ROW_ARTICLE_NUMBER>
            <OOI_ROW_QUANTITY2>7</OOI_ROW_QUANTITY2>
          </row>
          <row>
            <OOI_ROW_ARTICLE_NUMBER>BD3100</OOI_ROW_ARTICLE_NUMBER>
            <OOI_ROW_QUANTITY2>1</OOI_ROW_QUANTITY2>
          </row>
          <row>
            <OOI_ROW_ARTICLE_NUMBER>BD4000</OOI_ROW_ARTICLE_NUMBER>
            <OOI_ROW_QUANTITY2>1</OOI_ROW_QUANTITY2>
          </row>
        </rows>
      </order>
    </orders>
  </customers>
</xmlimexport>

Edited 5 Years Ago by xml_looser: n/a

Thanky you - almost right.

How to close a tag earlier? Now it closes at the end of the XML-file.
Now </Customers> closes last but I need to close it eirlier. (position 2 & 4

example:

<xmlimexport>
  <customers>
    <atKunder key="100" option="noedit" /> 
  </customers>
<orders>
  <order>
     <atOrder customerkey="100">
        OOI_HEAD_CUSTOMER_NUMBER>100</OOI_HEAD_CUSTOMER_NUMBER> 
     </atOrder>

Edited 5 Years Ago by nip: n/a

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output indent="yes" method="xml"/>
	<xsl:template match="/">
		<xmlimexport>
			<customers>
				<!-- I know not where they come from data -->
				<atKunder key="100" option="noedit"/>
                                <!--
				<xsl:apply-templates select="dataroot"/>
                                --> 
			</customers>
                        <xsl:apply-templates select="dataroot"/>
		</xmlimexport>
	</xsl:template>
	<xsl:template match="dataroot">
		<orders>
			<order>
                                <!-- I know not where they come from data -->
				<atOrder customerkey="100">					                                                                <OOI_HEAD_CUSTOMER_NUMBER>100</OOI_HEAD_CUSTOMER_NUMBER>
				</atOrder>
				<rows>
					<xsl:apply-templates select="gre"/>
				</rows>
			</order>
		</orders>
	</xsl:template>
	<xsl:template match="gre">
		<row>
			<OOI_ROW_ARTICLE_NUMBER>
				<xsl:value-of select="ARTNR"/>
			</OOI_ROW_ARTICLE_NUMBER>
			<OOI_ROW_QUANTITY2>
				<xsl:value-of select="Aktuellt"/>
			</OOI_ROW_QUANTITY2>
		</row>
	</xsl:template>
</xsl:stylesheet>

Using MS Office 7 to create an xml file from my talbe i get the following result (first t2 lines)

<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:

The result I am wanting is
<dataFile xmins=http//servicecanada.gc.ca/asest/asetsdata

I am unfamiliar with xml schema but can export my ms access table with no problem. the following is what I get and below is what I require for my client. If anyone can assist me with this I certainly would appreciate it and thank you all in advance. I am using MS Office 2007 and using the export option in access to convert to xml.

<?xml version="1.0" encoding="UTF-8" ?>
- <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ASETS%20HRSDC%20Funded%20Participant%20Make%20Table.xsd" generated="2011-03-29T11:39:36">
- <ASETS_x0020_HRSDC_x0020_Funded_x0020_Participant_x0020_Make_x0020_Table>
<Sin>123123123</Sin>
<Last_x0020_Name>Downey</Last_x0020_Name>
<First_x0020_Name>Denise</First_x0020_Name>
<DOB>1985-06-30T00:00:00</DOB>
<GenderID>2</GenderID>
<AborGroupID>1</AborGroupID>
<MaritalStat>2</MaritalStat>
<numberOfDependants>0</numberOfDependants>
<Disability>0</Disability>
<Street_x0020_Address>214 John</Street_x0020_Address>
<City>Moosonee</City>
<Prov>6</Prov>
<Postal_x0020_Code>P0P1W1</Postal_x0020_Code>
<HomePhone>8077668309</HomePhone>
<AgreementNumber>10216927</AgreementNumber>
<Main_x0020_Education>4</Main_x0020_Education>
<educationProvince>6</educationProvince>
<Social_x0020_Assistant_x0020_Recipient>0</Social_x0020_Assistant_x0020_Recipient>
<Barrier_x0020_To_x0020_Employment>5</Barrier_x0020_To_x0020_Employment>
<StartDate_x0020__x0028_Action_x0020_Plan_x0020_Start_x0020_Date_x0029_>2011-04-01T00:00:00</StartDate_x0020__x0028_Action_x0020_Plan_x0020_Start_x0020_Date_x0029_>
<CompletionDate_x0020__x0028_Action_x0020_Plan_x0020_End_x0020_Date_x0029_>2011-05-30T00:00:00</CompletionDate_x0020__x0028_Action_x0020_Plan_x0020_End_x0020_Date_x0029_>
<ActionPlanResultID_x0020__x0028_result_x0020_Code_x0029_>1</ActionPlanResultID_x0020__x0028_result_x0020_Code_x0029_>
<Action_x0020_Plan_x0020_Childcare_x0020_Need>0</Action_x0020_Plan_x0020_Childcare_x0020_Need>
<Action_x0020_Plan_x0020_Childcare_x0020_Funded>1</Action_x0020_Plan_x0020_Childcare_x0020_Funded>
<ContactDate>2011-05-30T00:00:00</ContactDate>
<InterventionOutcomeID>5</InterventionOutcomeID>
<Intervention_x0020_cost>10000</Intervention_x0020_cost>
<Intervention_x0020_End_x0020_Date>2011-05-31T00:00:00</Intervention_x0020_End_x0020_Date>
<Intervention_x0020_Duration>60</Intervention_x0020_Duration>
<InterventionRelatedNoc>4</InterventionRelatedNoc>
</ASETS_x0020_HRSDC_x0020_Funded_x0020_Participant_x0020_Make_x0020_Table>
</dataroot>


This is what is I require

<?xml version="1.0" encoding="UTF-8" ?>
- <dataFile xmlns="http://servicecanada.gc.ca/asets/asetsdata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://servicecanada.gc.ca/asets/asetsdata ASETS.xsd">
<SchemaVersion>1.1</SchemaVersion>
<agreementHolderName>agreementHolderName</agreementHolderName>
<sysComment>sysComment</sysComment>
- <client>
<socialInsuranceNumber>123456789</socialInsuranceNumber>
<lastName>lastName</lastName>
<initial>INITI</initial>
<firstName>firstName</firstName>
<dateOfBirth>2001-01-01</dateOfBirth>
<gender>1</gender>
<aboriginalGroup>1</aboriginalGroup>
<maritalStatus>1</maritalStatus>
<numberOfDependantChildren>0</numberOfDependantChildren>
<languageSpoken>1</languageSpoken>
<disability>true</disability>
- <address>
<streetAddress>streetAddress</streetAddress>
<municipality>municipality</municipality>
<province>1</province>
<postalZIPCode>A1B2C3</postalZIPCode>
<contactPhoneNumber>1-234-567-8901:2345</contactPhoneNumber>
<sysComment>sysComment</sysComment>
</address>
- <actionPlan>
<agreementNumber>098765432</agreementNumber>
<educationLevel>1</educationLevel>
<educationProvince>1</educationProvince>
<socialAssistanceRecipient>true</socialAssistanceRecipient>
<EIClaimant>1</EIClaimant>
<barrierToEmployment>1</barrierToEmployment>
<actionPlanStartDate>2001-01-01</actionPlanStartDate>
<actionPlanResultCode>1</actionPlanResultCode>
<actionPlanResultDate>2001-01-01</actionPlanResultDate>
<actionPlanChildCareNeed>true</actionPlanChildCareNeed>
<actionPlanChildCareFundedCode>1</actionPlanChildCareFundedCode>
- <intervention>
<interventionCode>1</interventionCode>
<interventionStartDate>2001-01-01</interventionStartDate>
<interventionEndDate>2001-01-01</interventionEndDate>
<interventionOutcome>1</interventionOutcome>
<interventionDuration>0</interventionDuration>
<interventionCost>0</interventionCost>
<interventionRelatedNOC>1234</interventionRelatedNOC>
<sysComment>sysComment</sysComment>
</intervention>
<sysComment>sysComment</sysComment>
</actionPlan>
<sysComment>sysComment</sysComment>
</client>
</dataFile>

This article has been dead for over six months. Start a new discussion instead.