cancel
Showing results for 
Search instead for 
Did you mean: 

path to CM file

Former Member
0 Kudos

Hi,

I want to read a file stored in Content Management in /documents/test/myfile.xml. For this I coded the following:

...

...

...

IResource aResource = null;

ResourceContext rContext = new ResourceContext(aUser);

RID aRid = RID.getRID("/documents/test/myfile.xml");

try

{

IResourceFactory aResourceFactory = ResourceFactory.getInstance();

aResource =

ResourceFactory.getInstance().getResource(aRid, rContext);

IContent con = aResource.getContent();

//there I can read the file ..etc..etc.

Now, I want to parse the myfile.xml. For this I made:

...

...

...

String xml = null;

SAXParserFactory factory = SAXParserFactory.newInstance();

SAXParser parser = null;

try

{

parser = factory.newSAXParser();

}

catch (ParserConfigurationException e3)

{

e3.printStackTrace();

}

catch (SAXException e3)

{

e3.printStackTrace();

}

try

{

parser.parse(<b>xml</b>, new Struct());

}

catch (SAXException e4)

{

e4.printStackTrace();

}

catch (IOException e4)

{

e4.printStackTrace();

}

...

...

...

The XML parser looking for myfile.xml in c:/documents/test/myfile.xml although this file is in Content Management. The http(access) link to myfile.xml is

http://localhost:50000/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/test/myfile.xml

How could I get the real path to myfile.xml(in CM) as regards with above access link ?

Thanks for any feedback or help

Regards.

Altafin

Accepted Solutions (0)

Answers (1)

Answers (1)

detlev_beutner
Active Contributor
0 Kudos

Hi Altafin,

1.) To make it easier to read code, you can set code fragments in [ code ] and [/ code ] (without spaces) to mark it.

2.) The code fragment given won't work for "xml" string being null. I think you have set the xml string to the RID-String?!

3.) Are you sure you want to use SAX-parser?

4.) Just use the InputStream you get from the content to be parsed.

Hope it helps

Detlev

Former Member
0 Kudos

Hi Detlev,

2. xml string is RID string

3. yes

4. I used for parse the InputStream and now it's working.

Regards.

Altafin