Transform XML inputs (files) to ACCESS outputs (table) using XSL2019 Community Moderator ElectionTransforming XML mixed nodes with disable-output-escapingXML to CSV using XSLT helpChrome, Firefox and Safari not applying XSLT? IE does!how to sort elements and group them based on unique element or ID, which has namespaceHow to Duplicate xml elementsXSLT - convert XML fileXSLT change value node based on the value of another nodeCamel: xsl transformation doesn't indent xmlhow to solve [org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 1; Content is not allowed in prolog.]XSL nodeset: do not find child elements by name
What wound would be of little consequence to a biped but terrible for a quadruped?
Do f-stop and exposure time perfectly cancel?
Is having access to past exams cheating and, if yes, could it be proven just by a good grade?
Counter-example to the existence of left Bousfield localization of combinatorial model category
validation vs test vs training accuracy, which one to compare for claiming overfit?
What Happens when Passenger Refuses to Fly Boeing 737 Max?
Playing ONE triplet (not three)
Good allowance savings plan?
Is "history" a male-biased word ("his+story")?
When were linguistics departments first established
what does the apostrophe mean in this notation?
When two POV characters meet
Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?
Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?
Is a lawful good "antagonist" effective?
Coworker uses her breast-pump everywhere in the office
Touchscreen-controlled dentist office snowman collector game
What is the definition of "Natural Selection"?
Best mythical creature to use as livestock?
Time dilation for a moving electronic clock
Replacing Windows 7 security updates with anti-virus?
"However" used in a conditional clause?
Format picture and text with TikZ and minipage
Making a sword in the stone, in a medieval world without magic
Transform XML inputs (files) to ACCESS outputs (table) using XSL
2019 Community Moderator ElectionTransforming XML mixed nodes with disable-output-escapingXML to CSV using XSLT helpChrome, Firefox and Safari not applying XSLT? IE does!how to sort elements and group them based on unique element or ID, which has namespaceHow to Duplicate xml elementsXSLT - convert XML fileXSLT change value node based on the value of another nodeCamel: xsl transformation doesn't indent xmlhow to solve [org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 1; Content is not allowed in prolog.]XSL nodeset: do not find child elements by name
I want to transform XML inputs (files) to ACCESS outputs (table) using XSL.
The XML files I have looks like this :
<?xml version="1.0"?>
<ZBE14_OEMs_ItemUpdate_IN>
<Record>
<Header>
<HEAD>HEADOEM</HEAD>
</Header>
<ItemMaster>
<CONO>800</CONO>
<WHLO>CA</WHLO>
<STAT>20</STAT>
<ITNO>PNA</ITNO>
<SPE3>SPE3 A</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ B</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>123</CSNO>
<UNMS>AA</UNMS>
</ItemMaster>
<Trailer>
<TRAIL>TRAILOEM</TRAIL>
</Trailer>
</Record>
<Record>
<Header>
<HEAD>HEADOEM</HEAD>
</Header>
<ItemMaster>
<CONO>800</CONO>
<WHLO>CB</WHLO>
<STAT>20</STAT>
<ITNO>PNB</ITNO>
<SPE3>SPE3 B</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ A</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>456</CSNO>
<UNMS>BB</UNMS>
</ItemMaster>
<Trailer>
<TRAIL>TRAILOEM</TRAIL>
</Trailer>
</Record>
</ZBE14_OEMs_ItemUpdate_IN>
What interested me is getting all the data in the <ItemMaster> section.
I don't know how to do this because the "Header" and "Trailer" tags bother me.
That's what I've managed to do so far:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ZBE14_OEMs_ItemUpdate_IN/Record/Header/HEAD/ItemMaster/">
<xsl:copy>
<xsl:apply-templates select="@*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Of course, that doesn't work, I'm really a beginner in XSL, so if you guys could help me, that would be much appreciated.
Thank you very much.
xml ms-access xslt
New contributor
Hich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I want to transform XML inputs (files) to ACCESS outputs (table) using XSL.
The XML files I have looks like this :
<?xml version="1.0"?>
<ZBE14_OEMs_ItemUpdate_IN>
<Record>
<Header>
<HEAD>HEADOEM</HEAD>
</Header>
<ItemMaster>
<CONO>800</CONO>
<WHLO>CA</WHLO>
<STAT>20</STAT>
<ITNO>PNA</ITNO>
<SPE3>SPE3 A</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ B</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>123</CSNO>
<UNMS>AA</UNMS>
</ItemMaster>
<Trailer>
<TRAIL>TRAILOEM</TRAIL>
</Trailer>
</Record>
<Record>
<Header>
<HEAD>HEADOEM</HEAD>
</Header>
<ItemMaster>
<CONO>800</CONO>
<WHLO>CB</WHLO>
<STAT>20</STAT>
<ITNO>PNB</ITNO>
<SPE3>SPE3 B</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ A</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>456</CSNO>
<UNMS>BB</UNMS>
</ItemMaster>
<Trailer>
<TRAIL>TRAILOEM</TRAIL>
</Trailer>
</Record>
</ZBE14_OEMs_ItemUpdate_IN>
What interested me is getting all the data in the <ItemMaster> section.
I don't know how to do this because the "Header" and "Trailer" tags bother me.
That's what I've managed to do so far:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ZBE14_OEMs_ItemUpdate_IN/Record/Header/HEAD/ItemMaster/">
<xsl:copy>
<xsl:apply-templates select="@*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Of course, that doesn't work, I'm really a beginner in XSL, so if you guys could help me, that would be much appreciated.
Thank you very much.
xml ms-access xslt
New contributor
Hich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Your XSLT states, that you want to generate XML. Is this correct? Is Access able to read XML?
– ceving
Mar 7 at 9:44
Yes, I want to import the data in the XML to a Access Table. But before importing, I want to transform them.
– Hich
Mar 7 at 9:53
Please add the expected result.
– michael.hor257k
Mar 7 at 11:36
add a comment |
I want to transform XML inputs (files) to ACCESS outputs (table) using XSL.
The XML files I have looks like this :
<?xml version="1.0"?>
<ZBE14_OEMs_ItemUpdate_IN>
<Record>
<Header>
<HEAD>HEADOEM</HEAD>
</Header>
<ItemMaster>
<CONO>800</CONO>
<WHLO>CA</WHLO>
<STAT>20</STAT>
<ITNO>PNA</ITNO>
<SPE3>SPE3 A</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ B</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>123</CSNO>
<UNMS>AA</UNMS>
</ItemMaster>
<Trailer>
<TRAIL>TRAILOEM</TRAIL>
</Trailer>
</Record>
<Record>
<Header>
<HEAD>HEADOEM</HEAD>
</Header>
<ItemMaster>
<CONO>800</CONO>
<WHLO>CB</WHLO>
<STAT>20</STAT>
<ITNO>PNB</ITNO>
<SPE3>SPE3 B</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ A</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>456</CSNO>
<UNMS>BB</UNMS>
</ItemMaster>
<Trailer>
<TRAIL>TRAILOEM</TRAIL>
</Trailer>
</Record>
</ZBE14_OEMs_ItemUpdate_IN>
What interested me is getting all the data in the <ItemMaster> section.
I don't know how to do this because the "Header" and "Trailer" tags bother me.
That's what I've managed to do so far:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ZBE14_OEMs_ItemUpdate_IN/Record/Header/HEAD/ItemMaster/">
<xsl:copy>
<xsl:apply-templates select="@*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Of course, that doesn't work, I'm really a beginner in XSL, so if you guys could help me, that would be much appreciated.
Thank you very much.
xml ms-access xslt
New contributor
Hich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I want to transform XML inputs (files) to ACCESS outputs (table) using XSL.
The XML files I have looks like this :
<?xml version="1.0"?>
<ZBE14_OEMs_ItemUpdate_IN>
<Record>
<Header>
<HEAD>HEADOEM</HEAD>
</Header>
<ItemMaster>
<CONO>800</CONO>
<WHLO>CA</WHLO>
<STAT>20</STAT>
<ITNO>PNA</ITNO>
<SPE3>SPE3 A</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ B</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>123</CSNO>
<UNMS>AA</UNMS>
</ItemMaster>
<Trailer>
<TRAIL>TRAILOEM</TRAIL>
</Trailer>
</Record>
<Record>
<Header>
<HEAD>HEADOEM</HEAD>
</Header>
<ItemMaster>
<CONO>800</CONO>
<WHLO>CB</WHLO>
<STAT>20</STAT>
<ITNO>PNB</ITNO>
<SPE3>SPE3 B</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ A</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>456</CSNO>
<UNMS>BB</UNMS>
</ItemMaster>
<Trailer>
<TRAIL>TRAILOEM</TRAIL>
</Trailer>
</Record>
</ZBE14_OEMs_ItemUpdate_IN>
What interested me is getting all the data in the <ItemMaster> section.
I don't know how to do this because the "Header" and "Trailer" tags bother me.
That's what I've managed to do so far:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ZBE14_OEMs_ItemUpdate_IN/Record/Header/HEAD/ItemMaster/">
<xsl:copy>
<xsl:apply-templates select="@*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Of course, that doesn't work, I'm really a beginner in XSL, so if you guys could help me, that would be much appreciated.
Thank you very much.
xml ms-access xslt
xml ms-access xslt
New contributor
Hich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Hich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited yesterday
Parfait
52.7k94471
52.7k94471
New contributor
Hich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Mar 7 at 9:36
HichHich
132
132
New contributor
Hich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Hich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Hich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Your XSLT states, that you want to generate XML. Is this correct? Is Access able to read XML?
– ceving
Mar 7 at 9:44
Yes, I want to import the data in the XML to a Access Table. But before importing, I want to transform them.
– Hich
Mar 7 at 9:53
Please add the expected result.
– michael.hor257k
Mar 7 at 11:36
add a comment |
Your XSLT states, that you want to generate XML. Is this correct? Is Access able to read XML?
– ceving
Mar 7 at 9:44
Yes, I want to import the data in the XML to a Access Table. But before importing, I want to transform them.
– Hich
Mar 7 at 9:53
Please add the expected result.
– michael.hor257k
Mar 7 at 11:36
Your XSLT states, that you want to generate XML. Is this correct? Is Access able to read XML?
– ceving
Mar 7 at 9:44
Your XSLT states, that you want to generate XML. Is this correct? Is Access able to read XML?
– ceving
Mar 7 at 9:44
Yes, I want to import the data in the XML to a Access Table. But before importing, I want to transform them.
– Hich
Mar 7 at 9:53
Yes, I want to import the data in the XML to a Access Table. But before importing, I want to transform them.
– Hich
Mar 7 at 9:53
Please add the expected result.
– michael.hor257k
Mar 7 at 11:36
Please add the expected result.
– michael.hor257k
Mar 7 at 11:36
add a comment |
1 Answer
1
active
oldest
votes
You have to define template rules for each node to handle them individually.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
The rule for the root node needs to output a new root node, because each XML needs a root node.
<xsl:template match="/ZBE14_OEMs_ItemUpdate_IN">
<import>
<xsl:apply-templates />
</import>
</xsl:template>
The input Record generates an output row for the import.
<xsl:template match="Record">
<row>
<xsl:apply-templates />
</row>
</xsl:template>
The ItemMaster should not be copied.
<xsl:template match="ItemMaster">
<xsl:apply-templates />
</xsl:template>
Header and Trailer should be ignored.
<xsl:template match="Header|Trailer" />
Everything else should be copied.
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
This will generate the following output:
<import>
<row>
<CONO>800</CONO>
<WHLO>CA</WHLO>
<STAT>20</STAT>
<ITNO>PNA</ITNO>
<SPE3>SPE3 A</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ B</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>123</CSNO>
<UNMS>AA</UNMS>
</row>
<row>
<CONO>800</CONO>
<WHLO>CB</WHLO>
<STAT>20</STAT>
<ITNO>PNB</ITNO>
<SPE3>SPE3 B</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ A</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>456</CSNO>
<UNMS>BB</UNMS>
</row>
</import>
That's perfect. I owe you one. thanks again :)
– Hich
Mar 7 at 12:35
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Hich is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55040441%2ftransform-xml-inputs-files-to-access-outputs-table-using-xsl%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have to define template rules for each node to handle them individually.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
The rule for the root node needs to output a new root node, because each XML needs a root node.
<xsl:template match="/ZBE14_OEMs_ItemUpdate_IN">
<import>
<xsl:apply-templates />
</import>
</xsl:template>
The input Record generates an output row for the import.
<xsl:template match="Record">
<row>
<xsl:apply-templates />
</row>
</xsl:template>
The ItemMaster should not be copied.
<xsl:template match="ItemMaster">
<xsl:apply-templates />
</xsl:template>
Header and Trailer should be ignored.
<xsl:template match="Header|Trailer" />
Everything else should be copied.
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
This will generate the following output:
<import>
<row>
<CONO>800</CONO>
<WHLO>CA</WHLO>
<STAT>20</STAT>
<ITNO>PNA</ITNO>
<SPE3>SPE3 A</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ B</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>123</CSNO>
<UNMS>AA</UNMS>
</row>
<row>
<CONO>800</CONO>
<WHLO>CB</WHLO>
<STAT>20</STAT>
<ITNO>PNB</ITNO>
<SPE3>SPE3 B</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ A</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>456</CSNO>
<UNMS>BB</UNMS>
</row>
</import>
That's perfect. I owe you one. thanks again :)
– Hich
Mar 7 at 12:35
add a comment |
You have to define template rules for each node to handle them individually.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
The rule for the root node needs to output a new root node, because each XML needs a root node.
<xsl:template match="/ZBE14_OEMs_ItemUpdate_IN">
<import>
<xsl:apply-templates />
</import>
</xsl:template>
The input Record generates an output row for the import.
<xsl:template match="Record">
<row>
<xsl:apply-templates />
</row>
</xsl:template>
The ItemMaster should not be copied.
<xsl:template match="ItemMaster">
<xsl:apply-templates />
</xsl:template>
Header and Trailer should be ignored.
<xsl:template match="Header|Trailer" />
Everything else should be copied.
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
This will generate the following output:
<import>
<row>
<CONO>800</CONO>
<WHLO>CA</WHLO>
<STAT>20</STAT>
<ITNO>PNA</ITNO>
<SPE3>SPE3 A</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ B</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>123</CSNO>
<UNMS>AA</UNMS>
</row>
<row>
<CONO>800</CONO>
<WHLO>CB</WHLO>
<STAT>20</STAT>
<ITNO>PNB</ITNO>
<SPE3>SPE3 B</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ A</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>456</CSNO>
<UNMS>BB</UNMS>
</row>
</import>
That's perfect. I owe you one. thanks again :)
– Hich
Mar 7 at 12:35
add a comment |
You have to define template rules for each node to handle them individually.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
The rule for the root node needs to output a new root node, because each XML needs a root node.
<xsl:template match="/ZBE14_OEMs_ItemUpdate_IN">
<import>
<xsl:apply-templates />
</import>
</xsl:template>
The input Record generates an output row for the import.
<xsl:template match="Record">
<row>
<xsl:apply-templates />
</row>
</xsl:template>
The ItemMaster should not be copied.
<xsl:template match="ItemMaster">
<xsl:apply-templates />
</xsl:template>
Header and Trailer should be ignored.
<xsl:template match="Header|Trailer" />
Everything else should be copied.
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
This will generate the following output:
<import>
<row>
<CONO>800</CONO>
<WHLO>CA</WHLO>
<STAT>20</STAT>
<ITNO>PNA</ITNO>
<SPE3>SPE3 A</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ B</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>123</CSNO>
<UNMS>AA</UNMS>
</row>
<row>
<CONO>800</CONO>
<WHLO>CB</WHLO>
<STAT>20</STAT>
<ITNO>PNB</ITNO>
<SPE3>SPE3 B</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ A</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>456</CSNO>
<UNMS>BB</UNMS>
</row>
</import>
You have to define template rules for each node to handle them individually.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
The rule for the root node needs to output a new root node, because each XML needs a root node.
<xsl:template match="/ZBE14_OEMs_ItemUpdate_IN">
<import>
<xsl:apply-templates />
</import>
</xsl:template>
The input Record generates an output row for the import.
<xsl:template match="Record">
<row>
<xsl:apply-templates />
</row>
</xsl:template>
The ItemMaster should not be copied.
<xsl:template match="ItemMaster">
<xsl:apply-templates />
</xsl:template>
Header and Trailer should be ignored.
<xsl:template match="Header|Trailer" />
Everything else should be copied.
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
This will generate the following output:
<import>
<row>
<CONO>800</CONO>
<WHLO>CA</WHLO>
<STAT>20</STAT>
<ITNO>PNA</ITNO>
<SPE3>SPE3 A</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ B</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>123</CSNO>
<UNMS>AA</UNMS>
</row>
<row>
<CONO>800</CONO>
<WHLO>CB</WHLO>
<STAT>20</STAT>
<ITNO>PNB</ITNO>
<SPE3>SPE3 B</SPE3>
<FRE3>N</FRE3>
<UNNN>HAZ A</UNNN>
<HAC1/>
<HAC2/>
<ITGR>BAAEAA</ITGR>
<SPE5/>
<CSNO>456</CSNO>
<UNMS>BB</UNMS>
</row>
</import>
answered Mar 7 at 10:45
cevingceving
10.3k360104
10.3k360104
That's perfect. I owe you one. thanks again :)
– Hich
Mar 7 at 12:35
add a comment |
That's perfect. I owe you one. thanks again :)
– Hich
Mar 7 at 12:35
That's perfect. I owe you one. thanks again :)
– Hich
Mar 7 at 12:35
That's perfect. I owe you one. thanks again :)
– Hich
Mar 7 at 12:35
add a comment |
Hich is a new contributor. Be nice, and check out our Code of Conduct.
Hich is a new contributor. Be nice, and check out our Code of Conduct.
Hich is a new contributor. Be nice, and check out our Code of Conduct.
Hich is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55040441%2ftransform-xml-inputs-files-to-access-outputs-table-using-xsl%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Your XSLT states, that you want to generate XML. Is this correct? Is Access able to read XML?
– ceving
Mar 7 at 9:44
Yes, I want to import the data in the XML to a Access Table. But before importing, I want to transform them.
– Hich
Mar 7 at 9:53
Please add the expected result.
– michael.hor257k
Mar 7 at 11:36