Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CXTPPropExchangeXMLNode & CompactMode
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPPropExchangeXMLNode & CompactMode

 Post Reply Post Reply
Author
Message
jimmy View Drop Down
Senior Member
Senior Member


Joined: 11 November 2003
Location: Austria
Status: Offline
Points: 516
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimmy Quote  Post ReplyReply Direct Link To This Post Topic: CXTPPropExchangeXMLNode & CompactMode
    Posted: 28 August 2008 at 10:22am
Hello,

What is CompactMode ?
Why do i need this ?

i will only read a small xml file (LoadFromFile) and retrive Name with
PX_String( &px, "Name", strName, "");
But i don't get Name.
After i set CompactMode="1" , it work.
Why is this so ?

<?xml version="1.0" encoding="UTF-8"?>
<FB Name="AND" Comment="Some Comment" Revision="1.0" FolderPos="1" >
    <Outputs>
        <Out Name="OUT" DataType="bool" Initialized="true"/>
    </Outputs>
</FB>

  Jimmy

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 28 August 2008 at 1:23pm
CompactMode  switch way to store data:
 
with compact mode:
 
<FB Name="AND" />
 
without:
<FB> <Name>AND</Name> </FB>
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
jimmy View Drop Down
Senior Member
Senior Member


Joined: 11 November 2003
Location: Austria
Status: Offline
Points: 516
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimmy Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2008 at 5:46am
Hi,

Mean that i can't use this ?

<FB Name="AND">
  <Input Name="Input1>Some Text</Input>
  <Input Name="Input1>Some other Text</Input>
</FB>

Here i have attribute (Name) and other text.

  Jimmy


Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2008 at 4:12pm
With Compact mode can: PX_String( &px, "", strName, "");
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
jimmy View Drop Down
Senior Member
Senior Member


Joined: 11 November 2003
Location: Austria
Status: Offline
Points: 516
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimmy Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2008 at 6:11pm
Thanks

  Jimmy

Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Posted: 30 August 2008 at 7:10am
Sorry, but can you be a bit more precise?
How can I read the compact name tag?
And what if I have multiple compact tags? And mixing?
 
cpede
Back to Top
jimmy View Drop Down
Senior Member
Senior Member


Joined: 11 November 2003
Location: Austria
Status: Offline
Points: 516
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimmy Quote  Post ReplyReply Direct Link To This Post Posted: 01 September 2008 at 6:51am
Is there a simple way to enable ompact mode without CompactMode attribute  ?

  Jimmy

Now i do this
class CXTPPropExchangeXMLNodeEx : public CXTPPropExchangeXMLNode
{
public:
    CXTPPropExchangeXMLNodeEx(BOOL bLoading, CXTPDOMNodePtr xmlParentNode, LPCTSTR lpszSection)
        : CXTPPropExchangeXMLNode(bLoading, xmlParentNode, lpszSection)
    {
    }

    bool DeleteAttr(LPCTSTR lpszEntry)
    {
        USES_CONVERSION;
        CXTPDOMNodePtr xmlNodeEntryPtr;

        XTPXML::IXMLDOMNamedNodeMapPtr map;
        m_xmlSectionNode->get_attributes(&map);
        HRESULT hr = map->removeNamedItem(CT2BSTR(lpszEntry), &xmlNodeEntryPtr);
        if (FAILED(hr))
            return false;
        return true;
    }
    virtual BOOL OnBeforeExchange()
    {
        BOOL bOk = __super::OnBeforeExchange();
        SetCompactMode(TRUE);
        return bOk;
    }
};
Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Posted: 03 September 2008 at 4:54am
Please, how do I mix Compact modes in one XML file?
 
-cpede
Back to Top
jimmy View Drop Down
Senior Member
Senior Member


Joined: 11 November 2003
Location: Austria
Status: Offline
Points: 516
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimmy Quote  Post ReplyReply Direct Link To This Post Posted: 03 September 2008 at 5:40am
Hi,

i think, if compacteMode is enabled, you can
access with
PX_String( &px, "AttrName", strName, "");a attribute entry and
with
PX_String( &px, "", strName, ""); you can access the normal text
<Input AttrName="AttributeValue">Normal Text</Input>

  Jimmy

Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Posted: 03 September 2008 at 6:04am
But what if Compact mode is NOT enabled, how do I access the attributes?
I guess that this is the most normal case for external XML files, since the Compact attribute/tag is something invented by CodeJock?
 
-cpede
Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Posted: 01 November 2016 at 7:16am
Is this implemented in v17.3?

Can I access compact attributes and nodes in CXTPPropExchangeXMLNode?

Maybe something like this:
<item tag="Hi">
CodeJock
</item>

CString sText1;
PX_String(&sec, _T("item/tag"), sText1);
CString sText2;
PX_String(&sec, _T("item"), sText2);

sText1 + " " +sText2 = "Hi CodeJock"

Quote
OK, I got a little wiser. The m_bCompactMode flag is set after the first initialize, e.g. the first time a PX_String is called. So, If someone loads an external XML which requires compact mode for reading, it is not enough to specify px.SetCompactMode(TRUE) after px.LoadFromFile(xmlfile), since this flag is reset by the first PX_String or alike. This is because CompactMode is a value set in the XML by CJ, and not as such a flag you can specify on load. So the trick is to do a dummy PX_String and thereafter set px.SetCompactMode(TRUE), to read the content of an external XML which is formatted with a mix of both attributes and nodes.

-cpede
Product: Xtreme ToolkitPro (24.0.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.