Using XPath to create Document node
Hi, could anyone suggest how to create Document nodes using xpaths with the help of some api (dom4j, JAXP, etc)?
For example:
With xpath="//A/B", I need to produce:
<A>
<B>.. </B>
</A>
XPath is usually used for querying XML document, but now I need to do the reverse.
Thanks.
DrClap, thanks for your reply.
Yes, the topic title is a bit misleading. I shouldn't call it "Document" node.
"And you have an XPath expression of a very restricted form which is supposed to describe the structure of that document."
Not really, what I have is a bunch of xpath expressions, each of them describe a element in a xml.
With these xpath expressions, in the end of the day I need to create a xml document with these elements.
For example, if I have
//A/B
//A/C
//A/D
I need to create a xml like this:
<A>
<B> ...</B>
<C>....</C>
<D>.....</D>
</A>
While I could do this in a manual way (creating each element from the root and adding children one by one....), I'm sure dom4j (or other packages) can do this but I couldn't find how.
Similar Messages
-
Hi,
Obviously the main use of XPath is to query the state of an XML document... the equivalent to a "select" statement in SQL.
DOM4J has methods that allow you to use XPath as the equivalent to "insert" statements in SQL. You can specify an XPath like "/Hello/World/Value = 3" and apply this XPath to an XML document so that it creates something like this for you:
<Hello>
<World>
<Value>3</Value>
</World>
</Hello>
This is actually very useful for an investment banking application that I'm working on.
The problem with DOM4J is that it doesn't handle attributes or conditionals well. If you specify
/Hello[@name=2]/World = 3
I would expect
<Hello name=2>
<World>3</World>
</Hello>
to be produced. Instead, it produces
<Hello[@name=2]>
<World>3</World>
</Hello>
These are all simple examples. What I'm doing in real life is using XPath to insert nodes into a complicated XML document that already has a lot of structure. I'm only adding one or two elements to big documents.
Is there anything at all like this available in the JDK 1.5 release. I've had a good look, and XPath looks like it's only for queries. Is this correct?I think this might do what you need...
// Create a dummy XML document
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputStream bais = new ByteArrayInputStream("<test><e1/></test>".getBytes());
Document doc = db.parse(bais);
// Define the XPath expression to "select" the parent element in the document
XPath xpath = XPathFactory.newInstance().newXPath();
XPathExpression xpathExpression = xpath.compile("/test/e1");
// Select the parent node (should probably chuck an ex if not present)
Node node = (Node) xpathExpression.evaluate(doc, XPathConstants.NODE);
// Create and append the child element
node.appendChild(doc.createElement("newElement"));
// Convert the Document into a string
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(baos);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.transform(source, result);
// <?xml version="1.0" encoding="UTF-8"?><test><e1><newElement/></e1></test>
System.out.println(baos.toString()); -
Using xpath expressions in Document-Builder
Hi all
we have re-designed our (existing) DDX-templates with the Document Builder in LC Workbench. The DDX templates are used to assemble PDFs with LC Assembler-Service.
Now my question: Is it still possible to use XPath-expression in the DDX template? Please find our example below:
The XPath expression works only if we copy&paste the DDX source code directly to the Assembler-Service property view (picture below). But referring the DDX-template doens't interpret the xpath path at run time (2nd picture below). Any help on that will be appreciated!
Works (using DDX source code directly):
Doesn't work (using DDX template):Hi,
>
I tried to get a portion of an XML by using XPath Expressions as follows:
String xPathExpression =
"declare namespace xq='http://inti.notariado.org/indices' " +
"$this/xq:RULES/xq:RULE[@disabled]";
I think any XPath expressions which use [] are not supported in stand alone
version, but as this is not documented I could be wrong.
Regards
Arek -
Using xpath to get parent nodes
hi! i�m trying to copy some elements from a xml file, and i have some problems.
i have this file
?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="xslpath.xsl"?>
<bookstore>
<book id="0">
<title id="pt">Harry Magico</title>
<desc id="1">
<price id="3">29.99</price>
<price1 id="3">329.95</price1>
</desc>
<name>nome</name>
</book>
</bookstore>
i�m using a xsl to copy the nodes.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:copy-of select="/bookstore/book/title/ancestor-or-self::price1"/> <!--not correct-->
</xsl:template>
</xsl:stylesheet>
well, if i select price1 node, what i want to get is:
<?xml version="1.0" encoding="utf-8"?>
<bookstore>
<book id="0">
<desc id="1">
<price1 id="3">329.95</price1>
</desc>
</book>
</bookstore>
i just want copy the node without is "brothers" :) and with is parents.
can anyone help me?hi! i�m trying to copy some elements from a xml file,
and i have some problems.
i have this file
?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"
href="xslpath.xsl"?>
<bookstore>
<book id="0">
<title id="pt">Harry Magico</title>
<desc id="1">
<price id="3">29.99</price>
<price1 id="3">329.95</price1>
</desc>
<name>nome</name>
</book>
</bookstore>
i�m using a xsl to copy the nodes.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<xsl:copy-of
select="/bookstore/book/title/ancestor-or-self::price
"/> <!--not correct-->
</xsl:template>
l:stylesheet>
well, if i select price1 node, what i want to get
is:
<?xml version="1.0" encoding="utf-8"?>
<bookstore>
<book id="0">
<desc id="1">
<price1 id="3">329.95</price1>
</desc>
</book>
</bookstore>
i just want copy the node without is "brothers" :)
and with is parents.
can anyone help me?right off my head, try this:
/bookstore/book/title/desc/price1/ancestor-or-self::* -
Create document using BAPI_DOCUMENT_CREATE2
Hi Experts,
i am using BAPI_DOCUMENT_CREATE2 to create document like transaction CV01N. When i create it through CV01N, it is fine and I can see the attached file.
but when i run my program, the document is created without attached file. can anyone have some solutions for me? following is the code.
REPORT ztest_fw.
DATA:
lv_docnum TYPE BAPI_DOC_AUX-DOCNUMBER,
LW_DOCDATA TYPE BAPI_DOC_DRAW2,
LW_RETURN TYPE BAPIRET2,
LW_DSP TYPE BAPI_DOC_DRAT,
LW_OBJLINK TYPE BAPI_DOC_DRAD,
LW_DOCFILE TYPE BAPI_DOC_FILES2,
LT_DSP TYPE STANDARD TABLE OF BAPI_DOC_DRAT,
LT_OBJLINK TYPE STANDARD TABLE OF BAPI_DOC_DRAD,
LT_DOCFILE TYPE STANDARD TABLE OF BAPI_DOC_FILES2.
START-OF-SELECTION.
CLEAR LW_DOCDATA.
LW_DOCDATA-DOCUMENTTYPE = 'DRW'.
LW_DOCDATA-documentversion = '00'.
LW_DOCDATA-documentpart = '000'.
LW_DOCDATA-laboratory = '001'.
CLEAR LW_DSP.
LW_DSP-DESCRIPTION = 'Test created by Fang wei-SD'.
LW_DSP-LANGUAGE = 'E'.
APPEND LW_DSP TO LT_DSP.
LW_DOCFILE-DOCFILE = 'D:\Function study\Inbound & Outbound IDoc user exits.pdf'.
LW_DOCFILE-ORIGINALTYPE = '1'.
LW_DOCFILE-STORAGECATEGORY = 'SAP-SYSTEM'.
LW_DOCFILE-STORAGECATEGORY = 'DMS_C1_ST'.
LW_DOCFILE-WSAPPLICATION = 'PDF'.
LW_DOCFILE-LANGUAGE = 'E'.
LW_DOCFILE-CHECKEDIN = 'X'.
LW_DOCFILE-ACTIVE_VERSION = 'X'.
APPEND LW_DOCFILE TO LT_DOCFILE.
CLEAR LW_OBJLINK.
LW_OBJLINK-OBJECTTYPE = 'IFLOT'.
LW_OBJLINK-OBJECTKEY = '1350'.
LW_OBJLINK-DOCUMENTDIRECTION = 'X'.
APPEND LW_OBJLINK TO LT_OBJLINK.
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
DOCUMENTDATA = LW_DOCDATA
IMPORTING
DOCUMENTNUMBER = lv_docnum
RETURN = LW_RETURN
TABLES
DOCUMENTDESCRIPTIONS = LT_DSP
OBJECTLINKS = LT_OBJLINK
DOCUMENTFILES = LT_DOCFILE.
IF LW_RETURN-TYPE CA 'EA'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
MESSAGE ID LW_RETURN-ID
TYPE LW_RETURN-TYPE
NUMBER LW_RETURN-NUMBER.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
CLEAR lw_return.
CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN2'
EXPORTING
DOCUMENTTYPE = 'DRW'
DOCUMENTNUMBER = lv_docnum
DOCUMENTPART = '000'
DOCUMENTVERSION = '00'
IMPORTING
RETURN = lw_return
TABLES
DOCUMENTFILES = lt_docfile
IF LW_RETURN-TYPE CA 'EA'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
MESSAGE ID LW_RETURN-ID
TYPE LW_RETURN-TYPE
NUMBER LW_RETURN-NUMBER.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
WRITE: / 'document number = ', lv_docnum.
ENDIF.
ENDIF.Hi Wei,
based on your description I would kindly ask you to check if the flag 'USE KPRO' is set for the document type 'DRW'. Because as storage category you hand over the value 'SAP-SYSTEM' and this is not a KPRO storage category. So if the 'USE KPRO' flag is set then this original won't be displayed in CV03N.
Is there maybe a difference in display between transaction CV02N and CV03N?
Best regards,
Christoph -
How to use xpath function to select some particular nodes
Dear experts:
does abap supports xpath to sellect particular nodes according some node value or condition, i know other programe language supports the function selectNode(xpath expression) , does abap or have the api to support it?
and i know there is a class support the xpath but it's not work., the class this:cl_xslt_processor
to clarify my point. i take a ex.
the xml doc is follow:
<?xml version="1.0" encoding="utf-8" ?>
- <n0:MT_CRM_Req xmlns:n0="http://gome.com/CRM/CRM/Outbound" xmlns:prx="urn:sap.com:proxy:DC0:/1SAI/TAS05C79364B9D0DC5F6738:701:2010/02/19">
<company name="hp">
<dep name="gds">
<empolyeeid>123</empolyeeid>
</dep>
<dep name="its">
<empolyeeid>148</empolyeeid>
</dep>
</company>
<company name="foxconn">
<dep name="fih">
<empolyeeid>569</empolyeeid>
</dep>
</company>
</n0:MT_CRM_Req>
i want to select the employee 's company name who empolyee id is 123
i use the method ,and the code is :
l_xslt->set_expression(
expression = '/n0:MT_CRM_Req/n0:company[n0:dep/n0:empolyeeid=123]'
nsdeclarations = 'n0 http://gome.com/CRM/CRM/Outbound'
l_xslt->run('').
nodes = l_xslt->get_nodes( ).
LEN = nodes->GET_LENGTH( ) .
WRITE LEN.
but no nodes return.
is anybody knows what's wrong with it? or there is some other api to manipulate the xml dom.
best regrds!Hello Kevin ,
i think you can get those details , have a look at program BCCIIXMLT1, i think this program will give you some idea to handle * manage xml docs.
along with that program ...you need to put filter
*---creating filers.
filter = document->create_filter_name( name = 'Company' ).
iterator = document->create_iterator_filtered( filter ).
main_node = document.
*---processing document.
perform print_node using main_node p_flag.
let me know if you need anymore help.
regards
Prabhu -
Xslt copy-of creates a xml which returns empty while trying to access elements using XPATH
Hi
I am trying to do a copy-of function using the XSLT in jdev. This is what I do
<xsl:param name="appdataDO"/>
<xsl:template match="/">
<ns1:applicationData>
<ns1:applicationId>
<xsl:value-of select="$appdataDO/ns1:applicationData/ns1:applicationId"/>
</ns1:applicationId>
<xsl:copy-of select="/fslo:ExternalapplicationData/fslo:ApplicationsHDRAddInfo">
</xsl:copy-of>
</ns1:applicationData>
</xsl:template>
</xsl:stylesheet>
After this I can see the document created in the process flow as this :
<ns1:applicationData>
<ns1:applicationId>MMMM</ns1:applicationId>
<ns2:ApplicationsHDRAddInfo>
<ns3:genericFromBasePrimitive>iuoui</ns3:genericFromBasePrimitive>
<ns4:EstimatedMarketValue>77</ns4:EstimatedMarketValue>
<ns4:PropertyInsuranceFee>jih</ns4:PropertyInsuranceFee>
<ns4:LoanOriginationFee>hjh</ns4:LoanOriginationFee>
<ns4:RegistrarFee>kkkkk</ns4:RegistrarFee>
<ns4:LoanCashInFee>hjh</ns4:LoanCashInFee>
<ns4:LoanPaidInCashFlag>cddffgd</ns4:LoanPaidInCashFlag>
</ns2:ApplicationsHDRAddInfo>
</ns1:applicationData>
But whenever I am trying to extract any of the output nodes I am getting an empty result. I can copy the whole dataset into similar kind of variable.
But I am unable to get individual elements using XPATH.
I tried using exslt function for node set and xslt 2.0 without avail.
The namespaces might be the culprit here . The test method in the jdev is able to output a result but at runtime the xpath returns empty .
I have created another transform where I try to copy data from the precious dataobject to a simple string in another data object .
This is the test sample source xml for the transform created by jdev while testing with all namespaces, where I try to copy the data in a simple string in another data object.
<applicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/bpmpa/fs/ulo/types file:/C:/JDeveloper/NewAPP/Xfrm/xsd/ApplicationData.xsd" xmlns="http://xmlns.oracle.com/bpmpa/fs/ulo/types">
<applicationId>applicationId289</applicationId>
<ApplicationsHDRAddInfo>
<genericFromBasePrimitive xmlns="http://xmlns.oracle.com/bpm/pa/extn/types/BasePrimitive">genericFromBasePrimitive290</genericFromBasePrimitive>
<EstimatedMarketValue xmlns="http://xmlns.oracle.com/bpm/pa/extn/headerCategories/">291</EstimatedMarketValue>
<PropertyInsuranceFee xmlns="http://xmlns.oracle.com/bpm/pa/extn/headerCategories/">PropertyInsuranceFee292</PropertyInsuranceFee>
<LoanOriginationFee xmlns="http://xmlns.oracle.com/bpm/pa/extn/headerCategories/">LoanOriginationFee293</LoanOriginationFee>
<RegistrarFee xmlns="http://xmlns.oracle.com/bpm/pa/extn/headerCategories/">RegistrarFee294</RegistrarFee>
<LoanCashInFee xmlns="http://xmlns.oracle.com/bpm/pa/extn/headerCategories/">LoanCashInFee295</LoanCashInFee>
<LoanPaidInCashFlag xmlns="http://xmlns.oracle.com/bpm/pa/extn/headerCategories/">LoanPaidInCashFlag296</LoanPaidInCashFlag>
</ApplicationsHDRAddInfo>
</applicationData>
And the xslt
<xsl:template match="/">
<ns1:DefaultOutput>
<ns1:attribute1>
<xsl:value-of select="/fslo:applicationData/fslo:ApplicationsHDRAddInfo/custom:LoanOriginationFee"/>
</ns1:attribute1>
</ns1:DefaultOutput>
</xsl:template>
This results in a empty attribute1. Any help will be appreciated .Please delete attributeFormDefault="qualified" elementFormDefault="qualified" from your XSD
Please check the next link:
http://www.oraclefromguatemala.com.gt/?p=34 -
Hi all,
I am learning XPATH and XQUERY from the Book "Pro T-SQL 2008 Programmer's Guide" written by Michael Coles, (published by apress). I copied the Code Listing 12-8 FOR XML PATH Using XPath Node Tests (listed below) and executed it in my
SQL Server 2012 Management Studio:
--Coles12_8.sql // saved in C:/Documemnts/SQL Server Management Studio
-- Coles Listing 12-8 FOR XML PATH Using XPATH Node Tests
-- Retrieving Name and E-mail Addresses with FOR XML PATH in AdvantureWorks
-- 16 March 2015 0935 AM
USE AdventureWorks;
GO
SELECT
p.NameStyle AS "processing-instruction(nameStyle)",
p.BusinessEntityID AS "Person/@ID",
p.ModifiedDate AS "comment()",
pp.PhoneNumber AS "test()",
FirstName AS "Person/Name/First",
MiddleName AS "Person/Name/Middle",
LastName AS "Person/Name/Last",
EmailAddress AS "Person/Email"
FROM Person.Person p
INNER JOIN Person.EmailAddress e
ON p.BusinessEntityID = e.BusinessEntityID
INNER JOIN Person.PersonPhone pp
ON p.BusinessEntityID = pp.BusinessEntityID
FOR XML PATH;
I got the following error message:
Msg 6850, Level 16, State 1, Line 2
Column name 'test()' contains an invalid XML identifier as required by FOR XML; '('(0x0028) is the first character at fault.
I have no ideas why I got this error message. Please kindly help and advise me how to resolve this error.
Thanks in advance, Scott ChangHi Michelle, Thanks for your nice response.
I corrected the mistake and executed the revised code. It worked nicely.
I just have one question to ask you about the appearance of the xml output of my Co;les12_8.sql:
<row>
<?nameStyle 0?>
<Person ID="1" />
<!--2003-02-08T00:00:00-->697-555-0142<Person><Name><First>Ken</First><Middle>J</Middle><Last>Sánchez</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="2" />
<!--2002-02-24T00:00:00-->819-555-0175<Person><Name><First>Terri</First><Middle>Lee</Middle><Last>Duffy</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="3" />
<!--2001-12-05T00:00:00-->212-555-0187<Person><Name><First>Roberto</First><Last>Tamburello</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="4" />
<!--2001-12-29T00:00:00-->612-555-0100<Person><Name><First>Rob</First><Last>Walters</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="5" />
<!--2002-01-30T00:00:00-->849-555-0139<Person><Name><First>Gail</First><Middle>A</Middle><Last>Erickson</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="6" />
<!--2002-02-17T00:00:00-->122-555-0189<Person><Name><First>Jossef</First><Middle>H</Middle><Last>Goldberg</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="7" />
<!--2003-03-05T00:00:00-->181-555-0156<Person><Name><First>Dylan</First><Middle>A</Middle><Last>Miller</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="8" />
<!--2003-01-23T00:00:00-->815-555-0138<Person><Name><First>Diane</First><Middle>L</Middle><Last>Margheim</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="9" />
<!--2003-02-10T00:00:00-->185-555-0186<Person><Name><First>Gigi</First><Middle>N</Middle><Last>Matthew</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="10" />
<!--2003-05-28T00:00:00-->330-555-2568<Person><Name><First>Michael</First><Last>Raheem</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="11" />
<!--2004-12-29T00:00:00-->719-555-0181<Person><Name><First>Ovidiu</First><Middle>V</Middle><Last>Cracium</Last></Name><Email>[email protected]</Email></Person></row>
<row>
I feel this xml output is not like the regular xml output. Do you know why it is diffrent from the regular xml xml output? Please comment on this matter.
Thanks,
Scott Chang
What do you mean by regular xml document? Are you referring to fact that its missing a root element? if yes it can be added as below
USE AdventureWorks;
GO
SELECT
p.NameStyle AS "processing-instruction(nameStyle)",
p.BusinessEntityID AS "Person/@ID",
p.ModifiedDate AS "comment()",
pp.PhoneNumber AS "text()",
FirstName AS "Person/Name/First",
MiddleName AS "Person/Name/Middle",
LastName AS "Person/Name/Last",
EmailAddress AS "Person/Email"
FROM Person.Person p
INNER JOIN Person.EmailAddress e
ON p.BusinessEntityID = e.BusinessEntityID
INNER JOIN Person.PersonPhone pp
ON p.BusinessEntityID = pp.BusinessEntityID
FOR XML PATH('ElementName'),ROOT('RootName');
replace ElementName and RootName with whatever name you need to set for element as well as the root element
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
How to extract node value by using xpath in orchestration shape
i want extract the node value by using xpath in expression shape in orch, then assign to variable.
then decide shape in if branch im using check condition based nodevalue .
str = xpath(Message_3, ("string(/*[local-name()='Root' and namespace-uri()='http://BizTalk_Server_ProjectRNd2.Schema3']/*[local-name()='no' and namespace-uri()=''])"));
but i got below error:
xlang/s engine event log entry: Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'BizTalk_Server_ProjectRNd2.BizTalk_Orchestration1(f3c581d3-049f-8a8a-9316-fc1235b03f99)'.
The service instance will remain suspended until administratively resumed or terminated.
If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
InstanceId: 020779be-713d-408c-9ff4-fd1462c2e52c
Shape name: Expression_1
ShapeId: b865a3e1-7ebe-410d-9f60-8ad2139ad234
Exception thrown from: segment 1, progress 10
Inner exception: There is an error in the XML document.
Exception type: InvalidOperationException
Source: System.Xml
Target Site: System.Object Deserialize(System.Xml.XmlReader, System.String, System.Xml.Serialization.XmlDeserializationEvents)
The following is a stack trace that identifies the location where the exception occured
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at Microsoft.XLANGs.Core.Part.XPathLoad(Part sourcePart, String xpath, Type dstType)
at BizTalk_Server_ProjectRNd2.BizTalk_Orchestration1.segment1(StopConditions stopOn)
at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
Additional error information:
<no xmlns=''> was not expected.
Exception type: InvalidOperationException
Source: System.Xml
Target Site: System.Object Read_string()
The following is a stack trace that identifies the location where the exception occured
at System.Xml.Serialization.XmlSerializationPrimitiveReader.Read_string()
at System.Xml.Serialization.XmlSerializer.DeserializePrimitive(XmlReader xmlReader, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)Hi,
as per your code i got below error
Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'BizTalk_Server_ProjectRNd2.BizTalk_Orchestration1(f3c581d3-049f-8a8a-9316-fc1235b03f99)'.
The service instance will remain suspended until administratively resumed or terminated.
If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
InstanceId: f5fffb05-e6d6-4765-83da-4e6c9696dd8a
Shape name: Expression_1
ShapeId: b865a3e1-7ebe-410d-9f60-8ad2139ad234
Exception thrown from: segment 1, progress 10
Inner exception: There is an error in the XML document.
Exception type: InvalidOperationException
Source: System.Xml
Target Site: System.Object Deserialize(System.Xml.XmlReader, System.String, System.Xml.Serialization.XmlDeserializationEvents)
The following is a stack trace that identifies the location where the exception occured
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializat
this is my schema:
<?xml version="1.0" encoding="utf-16"
?>
<xs:schema xmlns="http://BizTalk_Server_ProjectRNd2.Schema3" xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
xmlns:ns0="https://BizTalk_Server_ProjectRNd2.PropertySchema" targetNamespace="http://BizTalk_Server_ProjectRNd2.Schema3" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<b:imports>
<b:namespace
prefix="ns0" uri="https://BizTalk_Server_ProjectRNd2.PropertySchema" location=".\PropertySchema.xsd"
/>
</b:imports>
</xs:appinfo>
</xs:annotation>
<xs:element name="Root">
<xs:annotation>
<xs:appinfo>
<b:properties>
<b:property
name="ns0:no" xpath="/*[local-name()='Root' and namespace-uri()='http://BizTalk_Server_ProjectRNd2.Schema3']/*[local-name()='no' and namespace-uri()='']"
/>
</b:properties>
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element
name="no" type="xs:string" />
<xs:element
name="name" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema> -
Creating a node in an XML Document
Hi!
i need to insert a new element in an existing xml document. for example,
<bookinfo>
<book>
<bookname>A</bookname>
<author>B</author>
</book>
<book>
<bookname>C</bookname>
<author>D</author>
</book>
</bookinfo>
In this document if i want to insert another element using Xpath, say,<publisher> in <book> node, how to insert it.
I'm using DOM parser for parsing the xml file.
Any help to solve this issue appreciated.
Thanks in advance.final class Foo {
private static final String MARKUP =
"<bookinfo>\n" +
"<book isbn='1234'>\n" +
"<bookname>A</bookname>\n" +
"<author>B</author>\n" +
"</book>\n" +
"<book isbn='5678'>\n" +
"<bookname>C</bookname>\n" +
"<author>D</author>\n" +
"</book>\n" +
"</bookinfo>";
private Foo() {
super();
public static final void main(final String[] args)
throws XPathExpressionException {
String isbn = args.length > 0 ? args[0] : "1234";
String publisher = args.length > 1 ? args[1] : "Sample Publisher";
Document document = ... // Initialize somehow
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "//bookinfo/book[@isbn=" + isbn + "]";
Element book = (Element) xpath.evaluate(expression, document.getDocumentElement(), XPathConstants.NODE);
if (book == null) {
throw new RuntimeException("Unable to find ISBN " + isbn);
Element newPublisher = document.createElement("publisher");
newPublisher.setAttribute("name", publisher);
book.appendChild(newPublisher);
}- Saish -
Count multiple nodes in XML using xPath
Hi',
How to count the CUSTSERIAL node in the below XML using xPath.
<missingICCRec>
<MissingField xmlns="http://www.Google.com/MissingFields/v1.0">
<CUSTSERIAL xmlns="http://Google.com/InboundService">23809002RN</CUSTSERIAL>
<CUSTSERIAL xmlns="http://Google.com/InboundService">23809003RN</CUSTSERIAL>
<CUSTSERIAL xmlns="http://Google.com/InboundService">23809004RN</CUSTSERIAL>
</MissingField>
</missingICCRec>
Thanks
YatanYatan,
I created a simple BPEL with assign to count the node. Using ora:countNodes() function is throwing exception but when i tried with count() it works.
XSD seems to be valid. Only you need to have the function as below.
count(bpws:getVariableData('inputVariable','payload','/client:process/client:missingICCRec/client:MissingField/client:CUSTSERIAL'))
XSD Used:
<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://xmlns.oracle.com/PIMtoRPASAmendment/BPLENodeCount/BPLENodeCount"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="process">
<complexType>
<sequence>
<element name="missingICCRec">
<complexType>
<sequence>
<element name="MissingField">
<complexType>
<sequence>
<element name="CUSTSERIAL" maxOccurs="unbounded" type="string"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
<element name="processResponse">
<complexType>
<sequence>
<element name="result" type="string"/>
</sequence>
</complexType>
</element>
</schema>
This works !!!
Please let me know if this helps.
Thanks,
Vijay -
Extract Node Values using XPATH
This may be a repeat question.
No offence meant
I am using XPATH to extract values from the nodes.
I need to extract the value of i:RequestedBy Node using XPATH
<?xml version="1.0" encoding="UTF-8"?>
<i:Interest>
<i:Status>0</i:Status>
<i:Generation>2</i:Generation>
<i:Details xsi:type="i:vanilla.details.stock">
<i:RequestedBy>AA.MM</i:RequestedBy>
The above XML is of type Document
Document msgDoc;
XPath xpath = XPathFactory.newInstance().newXPath();
XPathExpression expr;
Object result=null;
try {
expr = xpath.compile("i:Interest/i:Details/i:RequestedBy/text()");
result = expr.evaluate(msgDoc, XPathConstants.NODESET);
NodeList nodes = (NodeList) result;
for (int i = 0; i < nodes.getLength(); i++) {
System.out.println(nodes.item(i).getNodeValue());
} catch (XPathExpressionException e1) {
e1.printStackTrace();
I am getting null/
Is my XPATH correct?I don't know if your XPath is correct or not. Your XML is not well-formed because the namespace declarations are missing. And I don't see where you set the namespace context for your XPath object; that is quite likely why it doesn't do what you want.
-
How to retrieve a node using xpath in java
Hi,
I need to make an application in which on click of a button an xml is
displayed on the browser.
Now when a user selects a node in the xml then i need the xpath of the selected node for some processing.
How to retrieve the xpath.
I am using Struts framework.There is not a specific method for achieving this.
You can store the whole xml document into a defined
structure. And get the needed xpath by some index.Yes i know that i'll need to store the file.
But my XML is fixed and the same XML is used everytime.
Now the structure of the XML is like it has same named nodes inside the parent node.
example :
<Human>
<Person>
<Person></Person>
<Person>
<Person><name>fsfsdsdf</name></Person>
</Person>
</Person>
<Human>
Now if the user selects the person node which contains name node then how to get the XPATH.
Can u help regarding the same........ -
How to add node value using org.w3c.dom.Document?
Hi ,
I'm using org.w3c.dom.Document to deal with xml files. I could successfully add nodes , and their attributes. However I could not add a value of the node. (e.g. <myNode>I couldn't add this value</myNode>)
does anyone know how to deal with this?
I tried subNode.setNodeValue("the value i can't add"); whereas the subNode is an instance of org.w3c.dom.Node... i know this is interface i of course used the concrete class
org.apache.crimson.tree.ElementNode
but when I used the subNode.getNodeValue() i simply got null?
can u plz help me?
thanks in advanceReading the API documentation for the Node interface might help. At least you wouldn't be surprised when the results are exactly what the documentation says they will be.
What would really help would be forgetting the idea that an Element can have a value. Text nodes have values, though, so create a Text node and make it the child of the Element node. -
Hi,
I wanted to know if an XML Document created in the Database using xPaths. I mean, I don't want to creat any XML file on the OS in the first place. I want to create an XML using a table containing xPaths. Can this be done in XDB ?
Thanks in Advance,
PiyushHi Piyush
I don't see how you can create a XML document via xpath!?!? xpath it's only used to reference data in an XML document...
Chris
Maybe you are looking for
-
Wi-Fi Slow for Mid-2010 MacBook Pro in Clamshell Mode
'd like to add my experience the posts which I have see regarding slow speeds in clamshell. I have a mid-2010 Macbook Pro 13 and when I first attempted to use it with an external monitor, keyboard and mouse - I too experienced significant slowing of
-
Myt iMac has slowed to a crawl
I attached a LaCie 2Big Thunderbolt drive yesterday, and last night bought aqnd loaded Quicktime Pro 7, and now my iMac is responding to mouse inputs about once every 30 seconds (as if the clock is either really slow, or it is very busy doing other t
-
External firewire drive won't mount
I've got an external Western Digital firewire drive that's been somewhat flaky recently, and today my Mac won't mount it. When I open Disk Utilities, I can see the drive (along with the other drives daisy chained together). When I click on "mount," I
-
Blackberry Bold 9700 won't Connect to Desktop
Everytime I connect my BB Bold to my PC in an attempt to back it up using the Blackberry Desktop software, it never actually connects. I have the latest version of the software on my pc...has this happeed to anyone?
-
AME CC cannot encode DV .mov at 23.98
Hey Adobe, please fix your broken preset for AME CC. It refuses to encode DV .mov files at 23.98 (this was a known issue in cs 6 as well) Even if I create a new DV 24p preset, It ALWAYS encodes them to 29.97--This is not helpful, It needs to work.