Member since
10-21-2015
3
Posts
0
Kudos Received
0
Solutions
09-27-2017
03:45 AM
You won't be able to do what you want with a single XPath, but this XSLT... <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:foo="***" exclude-result-prefixes="foo">
<xsl:template match="/DayInfo">
<xsl:for-each select="foo:TalkMessage/foo:Body/foo:person">
<xsl:result-document method="xml" href="person_{foo:id}.xml">
<DayInfo>
<TalkMessage xmlns="***">
<xsl:copy-of select="/DayInfo/foo:TalkMessage/foo:EnvelopeVersion" />
<xsl:copy-of select="/DayInfo/foo:TalkMessage/foo:Header" />
<xsl:copy-of select="/DayInfo/foo:TalkMessage/foo:TalkDetails" />
<xsl:element name="Body" namespace="***">
<xsl:copy-of select="." />
</xsl:element>
</TalkMessage>
</DayInfo>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
will convert this XML (which is similar to your sample XML response)... <?xml version="1.0" encoding="UTF-8"?>
<DayInfo>
<TalkMessage xmlns="***">
<EnvelopeVersion>**</EnvelopeVersion>
<Header>
<MessageDetails>
<Class>****</Class>
<Qualifier>*****</Qualifier>
<Function>***</Function>
<CorrelationID>*****</CorrelationID>
<ResponseEndPoint/>
</MessageDetails>
<SenderDetails>
<IDAuthentication/>
<EmailAddress/>
</SenderDetails>
</Header>
<TalkDetails>***</TalkDetails>
<Body>
<!-- with message like -->
<person>
<id>34</id>
<name>Moira Theriault</name>
</person>
<person>
<id>35</id>
<name>Cheree Meacham</name>
</person>
<person>
<id>36</id>
<name>Kris Demery</name>
</person>
<contact>...</contact>
<data>...</data>
</Body>
</TalkMessage>
</DayInfo>
and will create these three files, person_34.xml, person_35.xml, person_36.xml: <?xml version="1.0" encoding="UTF-8"?>
<DayInfo>
<TalkMessage xmlns="***">
<EnvelopeVersion>**</EnvelopeVersion>
<Header>
<MessageDetails>
<Class>****</Class>
<Qualifier>*****</Qualifier>
<Function>***</Function>
<CorrelationID>*****</CorrelationID>
<ResponseEndPoint/>
</MessageDetails>
<SenderDetails>
<IDAuthentication/>
<EmailAddress/>
</SenderDetails>
</Header>
<TalkDetails>***</TalkDetails>
<Body>
<person>
<id>34</id>
<name>Moira Theriault</name>
</person>
</Body>
</TalkMessage>
</DayInfo>
<?xml version="1.0" encoding="UTF-8"?>
<DayInfo>
<TalkMessage xmlns="***">
<EnvelopeVersion>**</EnvelopeVersion>
<Header>
<MessageDetails>
<Class>****</Class>
<Qualifier>*****</Qualifier>
<Function>***</Function>
<CorrelationID>*****</CorrelationID>
<ResponseEndPoint/>
</MessageDetails>
<SenderDetails>
<IDAuthentication/>
<EmailAddress/>
</SenderDetails>
</Header>
<TalkDetails>***</TalkDetails>
<Body>
<person>
<id>35</id>
<name>Cheree Meacham</name>
</person>
</Body>
</TalkMessage>
</DayInfo>
<?xml version="1.0" encoding="UTF-8"?>
<DayInfo>
<TalkMessage xmlns="***">
<EnvelopeVersion>**</EnvelopeVersion>
<Header>
<MessageDetails>
<Class>****</Class>
<Qualifier>*****</Qualifier>
<Function>***</Function>
<CorrelationID>*****</CorrelationID>
<ResponseEndPoint/>
</MessageDetails>
<SenderDetails>
<IDAuthentication/>
<EmailAddress/>
</SenderDetails>
</Header>
<TalkDetails>***</TalkDetails>
<Body>
<person>
<id>36</id>
<name>Kris Demery</name>
</person>
</Body>
</TalkMessage>
</DayInfo>
Of course, you'll need to include your actual namespace. If you don't have access to an XSLT 2.0 processor, you can use the <exslt:document> extension element to XSLT 1.0.
... View more
06-04-2017
12:15 AM
I think the error is a bash error rather than an XML error. Check the command line you are using to load the file for syntax errors, particularly misplaced <, >, or | characters. If you still think it is an XML problem and you are sure the first five characters in the file are '<?xml', then you can consider these XML oddities:
You have standalone="yes", which is incorrect, but should be ignored by the parser. The standalone document declaration is only considered if you have a <!DOCTYPE... defined (which you don't) and it should only be standalone="yes" if the DTD has information that could change your document such as entity declarations or required attributes. You have an empty value (<value/>) for the property with a name of "hive.metastore.uris"
... View more